예제 #1
0
        public void Delete(int id)
        {
            PlatformsDao toDelete = _ctx.Platforms.First(r => r.PlatformId == id);

            _ctx.Platforms.Remove(toDelete);
            _ctx.SaveChanges();
        }
예제 #2
0
        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));
        }
예제 #3
0
 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
     });
 }
예제 #4
0
        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();
        }