예제 #1
0
        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);
        }
예제 #2
0
        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);
        }
예제 #3
0
        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);
        }