public override ApplicationUserEntity Create(ApplicationUserEntity entity) { entity.Created = DateTime.Now; var ApplicationUser = base.Create(entity); serviceOfSearch.Create <ApplicationUserEntity>(ApplicationUser); IRepository <UserProfileEntity> repositoryOfUserProfile = new RepositoryOfUserProfile(context, serviceOfSearch); var UserProfile = repositoryOfUserProfile.Read(a => a.Id == ApplicationUser.UserProfileId); if (UserProfile == null) { UserProfile = new UserProfileEntity() { ApplicationUserId = ApplicationUser.Id }; UserProfile = repositoryOfUserProfile.Create(UserProfile); ApplicationUser.UserProfileId = UserProfile.Id; } this.Update(ApplicationUser); return(ApplicationUser); }
public override PostEntity Create(PostEntity entity) { IRepository <SectionEntity> repositoryOfSection = new RepositoryOfSection(context); var section = entity.Section; if (section == null) { section = repositoryOfSection.Read(a => a.Id == entity.SectionId); } if (section != null) { section.CountOfUsage++; repositoryOfSection.Update(section); } if (entity.IsFinished) { entity.Created = DateTime.Now; } entity = base.Create(entity); serviceOfSearch.Create <PostEntity>(entity); return(entity); }