From 361a7fe9d55f0b5b92ac18530eff88535af65d82 Mon Sep 17 00:00:00 2001 From: "arthur.valin" Date: Wed, 22 Mar 2023 19:58:02 +0100 Subject: [PATCH] Correcting bug --- .../Sources/Business/DbData.Champions.cs | 15 +++----- .../Sources/Business/DbData.Skins.cs | 2 +- .../Sources/EntityMappers/SkinEntity.cs | 37 ------------------- 3 files changed, 7 insertions(+), 47 deletions(-) delete mode 100644 EntityFramework_LoL/Sources/EntityMappers/SkinEntity.cs diff --git a/EntityFramework_LoL/Sources/Business/DbData.Champions.cs b/EntityFramework_LoL/Sources/Business/DbData.Champions.cs index ff05005..296d45d 100644 --- a/EntityFramework_LoL/Sources/Business/DbData.Champions.cs +++ b/EntityFramework_LoL/Sources/Business/DbData.Champions.cs @@ -24,17 +24,14 @@ namespace Business public async Task DeleteItem(Champion? item) { - try + var toDelete = parent.DbContext.champions.Find(item.Name); + if (toDelete!=null) { - var toDelete = parent.DbContext.champions.Find(item.Name); - if (toDelete!=null) - { - parent.DbContext.champions.Remove(toDelete); - parent.DbContext.SaveChanges(); - return true; - } - return false; + parent.DbContext.champions.Remove(toDelete); + parent.DbContext.SaveChanges(); + return true; } + return false; } public async Task> GetItems(int index, int count, string? orderingPropertyName = null, bool descending = false) diff --git a/EntityFramework_LoL/Sources/Business/DbData.Skins.cs b/EntityFramework_LoL/Sources/Business/DbData.Skins.cs index dafee84..2175f00 100644 --- a/EntityFramework_LoL/Sources/Business/DbData.Skins.cs +++ b/EntityFramework_LoL/Sources/Business/DbData.Skins.cs @@ -49,7 +49,7 @@ namespace Business return parent.DbContext.skins.Include("Champion").GetItemsWithFilterAndOrdering( s => s.Name.Contains(substring), index, count, - orderingPropertyName, descending).Select(s => s?.ToModel()); + orderingPropertyName, descending).Select(s => s.ToModel()); } public async Task GetNbItems() diff --git a/EntityFramework_LoL/Sources/EntityMappers/SkinEntity.cs b/EntityFramework_LoL/Sources/EntityMappers/SkinEntity.cs deleted file mode 100644 index 927dca3..0000000 --- a/EntityFramework_LoL/Sources/EntityMappers/SkinEntity.cs +++ /dev/null @@ -1,37 +0,0 @@ -using Shared; -using System; -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; -using System.ComponentModel.DataAnnotations.Schema; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Entities -{ - public class SkinEntity - { - [Key] - [MaxLength(256)] - public string Name { get; set; } - [Required] - [MaxLength(500)] - public string Description { get; set; } - [Required] - public string Icon { get; set; } - [Required] - public float Price { get; set; } - - [Required] - public string ChampionForeignKey { get; set; } - - [ForeignKey("ChampionForeignKey")] - public ChampionEntity Champion { get; set; } - - public Guid? ImageId { get; set; } - - [ForeignKey("ImageId")] - public LargeImageEntity? Image { get; set; } - - } -}