예제 #1
0
        public override ApplicationUserEntity Update(ApplicationUserEntity entity, params Expression <Func <ApplicationUserEntity, object> >[] properties)
        {
            var applicationUserEntity = base.Update(entity, properties);

            serviceOfSearch.Update <ApplicationUserEntity>(entity);
            return(applicationUserEntity);
        }
        public override PostEntity Update(PostEntity entity, params Expression <Func <PostEntity, object> >[] properties)
        {
            var lastPost = this.Read(a => a.Id == entity.Id, a => a.Section);
            IRepository <SectionEntity> repositoryOfSection = new RepositoryOfSection(context);

            if (entity.Section == null)
            {
                entity.Section = repositoryOfSection.Read(a => a.Id == entity.SectionId);
            }

            if (entity.Section != lastPost.Section)
            {
                if (lastPost.Section != null)
                {
                    lastPost.Section.CountOfUsage--;
                    repositoryOfSection.Update(lastPost.Section);
                }
                entity.Section.CountOfUsage++;
                repositoryOfSection.Update(entity.Section);
            }
            if (entity.Created.Millisecond == 0)
            {
                entity.Created = DateTime.Now;
            }
            serviceOfSearch.Update <PostEntity>(entity);
            entity = base.Update(entity, properties);
            return(entity);
        }