public async Task <bool> UpdateEssayAync(UpdateEssayModel updateEssayModel) { try { this.essaysRepository.Update(this.GenerateEssay(updateEssayModel)); } catch (System.Exception) { return(false); } await this.essaysRepository.SaveChangesAsync(); return(true); }
private UpdateEssayModel GenerateUpdateEssayModel(ReviewedEssayViewModel viewModel) { UpdateEssayModel updateEssayModel = new UpdateEssayModel() { Id = viewModel.Id, ImageUrl = viewModel.ImageUrl, Content = this.htmlSanitizer.Sanitize(viewModel.Content), Description = viewModel.Description, Title = viewModel.Title, UserId = viewModel.UserId, ContestId = viewModel.ContestId, }; return(updateEssayModel); }
private Essay GenerateEssay(UpdateEssayModel updateEssayModel) { var createdOn = this.essaysRepository.AllAsNoTracking().First(x => x.Id == updateEssayModel.Id).CreatedOn; Essay essay = new Essay() { Id = updateEssayModel.Id, ImageUrl = updateEssayModel.ImageUrl, UserId = updateEssayModel.UserId, Title = updateEssayModel.Title, Description = updateEssayModel.Description, Content = updateEssayModel.Content, ContestId = updateEssayModel.ContestId, Graded = true, CreatedOn = createdOn, }; return(essay); }