コード例 #1
0
        public void Delete(DalTheme entity)
        {
            var ormTheme = entity.ToOrmTheme();
            var theme    = context.Set <Theme>().FirstOrDefault(u => u.Id == ormTheme.Id);

            context.Set <Theme>().Attach(theme);
            context.Set <Theme>().Remove(theme);
            context.Entry(theme).State = System.Data.Entity.EntityState.Deleted;
        }
コード例 #2
0
        public void Delete(DalTheme entity)
        {
            var theme = context.Set <Theme>().Where(th => th.Id == entity.Id).FirstOrDefault();

            if (theme != null)
            {
                context.Set <Theme>().Remove(theme);
            }
        }
コード例 #3
0
 public void Update(DalTheme entity)
 {
     if (entity != null)
     {
         var themeToUpdate = context.Set <Theme>().FirstOrDefault(u => u.Id == entity.Id);
         var ormTheme      = entity.ToOrmTheme();
         context.Set <Theme>().Attach(themeToUpdate);
         themeToUpdate.Name = ormTheme.Name;
         context.Entry(themeToUpdate).State = System.Data.Entity.EntityState.Modified;
     }
 }
コード例 #4
0
        public void Update(DalTheme entity)
        {
            var theme = context.Set <Theme>().Where(th => th.Id == entity.Id).FirstOrDefault();

            if (theme != null)
            {
                theme.Name            = entity.Name;
                theme.DatePublication = entity.DatePublication;
                theme.CountViews      = entity.CountViews;
                theme.CreatorId       = entity.CreatorId;
                theme.SectionId       = entity.SectionId;
                theme.Content         = entity.Content;
            }
        }
コード例 #5
0
        public static Theme ToOrmTheme(this DalTheme dalTheme)
        {
            if (dalTheme == null)
            {
                return(null);
            }
            var ormTheme = new Theme()
            {
                Id   = dalTheme.Id,
                Name = dalTheme.Name
            };

            return(ormTheme);
        }
コード例 #6
0
        public static DalTheme ToDalTheme(this Theme ormTheme)
        {
            if (ormTheme == null)
            {
                return(null);
            }
            var dalTheme = new DalTheme()
            {
                Id   = ormTheme.Id,
                Name = ormTheme.Name,
            };

            return(dalTheme);
        }
コード例 #7
0
        public static BllTheme ToBllTheme(this DalTheme dalTheme)
        {
            if (dalTheme == null)
            {
                return(null);
            }
            var bllTheme = new BllTheme()
            {
                Id   = dalTheme.Id,
                Name = dalTheme.Name
            };

            return(bllTheme);
        }
コード例 #8
0
        public static DalTheme ToDalTheme(this BllTheme bllTheme)
        {
            if (bllTheme == null)
            {
                return(null);
            }
            var dalTheme = new DalTheme()
            {
                Id   = bllTheme.Id,
                Name = bllTheme.Name,
            };

            return(dalTheme);
        }
コード例 #9
0
        public void Create(DalTheme entity)
        {
            var theme = new Theme()
            {
                Id              = entity.Id,
                Name            = entity.Name,
                DatePublication = entity.DatePublication,
                CountViews      = entity.CountViews,
                CreatorId       = entity.CreatorId,
                SectionId       = entity.SectionId,
                Content         = entity.Content
            };

            context.Set <Theme>().Add(theme);
        }
コード例 #10
0
ファイル: ThemeMapper.cs プロジェクト: ekaterinatsmyg/Forum
 public static ThemeEntity ToBllTheme(this DalTheme dalTheme)
 {
     if (dalTheme != null)
     {
         return(new ThemeEntity()
         {
             Id = dalTheme.Id,
             Name = dalTheme.Name,
             DatePublication = dalTheme.DatePublication,
             CountViews = dalTheme.CountViews,
             CreatorId = dalTheme.CreatorId,
             SectionId = dalTheme.SectionId,
             Content = dalTheme.Content
         });
     }
     return(null);
 }
コード例 #11
0
        public void Create(DalTheme entity)
        {
            var theme = entity.ToOrmTheme();

            context.Set <Theme>().Add(theme);
        }