public void Delete(int id) { PlatformsDao toDelete = _ctx.Platforms.First(r => r.PlatformId == id); _ctx.Platforms.Remove(toDelete); _ctx.SaveChanges(); }
public Platform Read(int id, bool details) { PlatformsDao platformDao = details ? _ctx.Platforms.AsNoTracking().First(p => p.PlatformId == id) : _ctx.Platforms.First(p => p.PlatformId == id); ExtensionMethods.CheckForNotFound(platformDao, "Platform", id); return(ConvertToDomain(platformDao)); }
private Platform ConvertToDomain(PlatformsDao dao) { return(new Platform { Id = dao.PlatformId, Name = dao.Name, Url = dao.SiteUrl, CarouselImage = dao.CarouselImage, IconImage = dao.IconImage, FrontPageImage = dao.FrontPageImage }); }
public void Update(Platform obj) { PlatformsDao newPlatform = ConvertToDao(obj); PlatformsDao foundPlatform = _ctx.Platforms.FirstOrDefault(dto => dto.PlatformId == newPlatform.PlatformId); if (foundPlatform != null) { foundPlatform.Name = newPlatform.Name; foundPlatform.SiteUrl = newPlatform.SiteUrl; foundPlatform.IconImage = newPlatform.IconImage; foundPlatform.CarouselImage = newPlatform.CarouselImage; foundPlatform.FrontPageImage = newPlatform.FrontPageImage; _ctx.Platforms.Update(foundPlatform); } _ctx.SaveChanges(); }