public void Create(DalSection entity)
        {
            var section = entity.ToSection();

            section.SectionId = 0;
            _dbContext.Set <Section>().Add(section);
        }
        public void Delete(DalSection entity)
        {
            var section = entity.ToSection();

            section.Categories = _categoryRepository.GetCategoriesBySectionId(entity.Id).ToCategoryCollection();
            section            = _dbContext.Set <Section>().Single(s => s.SectionId == section.SectionId);
            _dbContext.Set <Section>().Remove(section);
        }
예제 #3
0
 public void Delete(DalSection entity)
 {
     var section = context.Set<Section>().Where(s => s.Id == entity.Id).FirstOrDefault();
     if (section != null)
     {
         context.Set<Section>().Remove(section);
     }
 }
예제 #4
0
 public static BllSection ToBllSection(this DalSection dalSection)
 {
     return(new BllSection()
     {
         Id = dalSection.Id,
         Name = dalSection.Name,
         Topics = dalSection.Topics.Select(t => t.ToBllTopic()),
     });
 }
예제 #5
0
 public void Update(DalSection entity)
 {
     var section = context.Set<Section>().Where(s => s.Id == entity.Id).FirstOrDefault();
     if (section != null)
     {
         section.Name = entity.Name;
         section.DateAdded = entity.DateAdded;
     }
 }
예제 #6
0
 public void Visit(DalSection dalSection)
 {
     CheckArgumentNull(dalSection);
     OrmEntity = new Section()
     {
         Id   = dalSection.Id,
         Name = dalSection.Name
     };
 }
예제 #7
0
 public void Create(DalSection entity)
 {
     var section = new Section()
     {
         Id = entity.Id,
         Name = entity.Name,
         DateAdded = entity.DateAdded
     };
     context.Set<Section>().Add(section);
 }
예제 #8
0
        /// <summary>
        /// Adding section
        /// </summary>
        /// <param name="entity">section for adding</param>
        public void Create(DalSection entity)
        {
            var section = new Section()
            {
                Id   = entity.Id,
                Name = entity.Name
            };

            context.Set <Section>().Add(section);
            context.SaveChanges();
        }
예제 #9
0
 public static SectionEntity ToBllSection(this DalSection dalSection)
 {
     if (dalSection != null)
     {
         return(new SectionEntity()
         {
             Id = dalSection.Id,
             Name = dalSection.Name
         });
     }
     return(null);
 }
예제 #10
0
 public static SectionEntity ToBllSection(this DalSection dalSection)
 {
     return(new SectionEntity()
     {
         Id = dalSection.Id,
         SectionName = dalSection.Name,
         PostsInSection = dalSection.PostsInSection.Select(p => new PostEntity()
         {
             Id = p.Id, Name = p.Name, AuthorLogin = p.AuthorLogin, DateOfPost = p.DateOfPost, SectionId = p.SectionId, AuthorId = p.AuthorId
         })
     });
 }
예제 #11
0
        public void CreateNewSection(DalSection e)
        {
            NullRefCheck();
            ArgumentNullCheck(e);
            var section = new Section()
            {
                Id   = e.Id,
                Name = e.Name,
            };

            context.Set <Section>().Add(section);
        }
예제 #12
0
        public void Delete(DalSection e)
        {
            NullRefCheck();
            ArgumentNullCheck(e);
            var section = new Section()
            {
                Id   = e.Id,
                Name = e.Name,
            };

            section = context.Set <Section>().Single(u => u.Id == section.Id);
            context.Set <Section>().Remove(section);
        }
예제 #13
0
 public static Section ToSection(this DalSection dalSection)
 {
     return(new Section()
     {
         CreationDate = dalSection.CreationDate,
         SectionId = dalSection.Id,
         IsBlocked = dalSection.IsBlocked,
         SectionName = dalSection.SectionName,
         UserRefId = dalSection.UserRefId,
         Discription = dalSection.Discription,
         Categories = dalSection.Categories.ToCategoryCollection()
     });
 }
        public void CreateSection()
        {
            var section = new DalSection()
            {
                CreationDate = DateTime.Now,
                IsBlocked    = false,
                SectionName  = "Stars",
                UserRefId    = 1
            };

            SectionRepository.Create(section);
            Context.SaveChanges();
        }
        public void Update(DalSection entity)
        {
            var existedSection = _dbContext.Entry <Section>(_dbContext.Set <Section>().Find(entity.Id));

            if (existedSection == null)
            {
                return;
            }
            existedSection.State              = EntityState.Modified;
            existedSection.Entity.IsBlocked   = entity.IsBlocked;
            existedSection.Entity.UserRefId   = entity.UserRefId;
            existedSection.Entity.Discription = entity.Discription;
            existedSection.Entity.SectionName = entity.SectionName;
        }
예제 #16
0
 public static SectionEntity ToBllSection(this DalSection dalSection)
 {
     return(new SectionEntity()
     {
         CreationDate = dalSection.CreationDate,
         Id = dalSection.Id,
         IsBlocked = dalSection.IsBlocked,
         SectionName = dalSection.SectionName,
         UserRefId = dalSection.UserRefId,
         ModeratorLogin = dalSection.ModeratorLogin,
         Discription = dalSection.Discription,
         CategoriesCount = dalSection.CategoriesCount,
         Categories = dalSection.Categories.ToCategoryEntityCollection()
     });
 }
예제 #17
0
        public void DeleteSection(int id)
        {
            DalSection section = sectionRepository.First(s => s.Id == id);

            foreach (var t in section.Topics.ToList())
            {
                t.Section.Id = 1;
                topicRepository.Update(t);
            }

            try
            {
                sectionRepository.Delete(id);
            }
            catch (InvalidOperationException e)
            {
                logger.Warn(e.Message);
                throw;
            }
        }
예제 #18
0
 public void Update(DalSection entity)
 {
     NullRefCheck();
     throw new NotImplementedException();
 }