Example #1
0
 public async Task EditAsync(EditQuestionViewModel viewModel)
 {
     var question = await _questions.FirstAsync(a => a.Id == viewModel.Id);
     _mappingEngine.Map(viewModel, question);
 }
Example #2
0
        public virtual async Task<ActionResult> Edit(EditQuestionViewModel viewModel)
        {
            if (!await _questionService.IsInDb(viewModel.Id))
                this.AddErrors("Body", "سوال مورد نظر توسط یکی از کاربران در شبکه،حذف شده است");

            if (!ModelState.IsValid)
            {
                return View(viewModel);
            }

            await _questionService.EditAsync(viewModel);
            var message = await _unitOfWork.ConcurrencySaveChangesAsync();
            if (message.HasValue())
                this.AddErrors("Title", string.Format(message, "سوال"));

            if (ModelState.IsValid) return RedirectToAction(MVC.Question.List());
            return View(viewModel);
        }
Example #3
0
        public virtual async Task<ActionResult> Edit(EditQuestionViewModel viewModel)
        {
            if (!await _questionService.IsInDb(viewModel.Id))
                this.AddErrors("Body", "سوال مورد نظر توسط یکی از کاربران در شبکه،حذف شده است");

            if (!ModelState.IsValid)
            {
                return View(viewModel);
            }
            await _questionService.EditAsync(viewModel);
            await _unitOfWork.SaveAllChangesAsync();
            return RedirectToAction(MVC.Question.List());
        }
Example #4
0
 public async Task EditAsync(EditQuestionViewModel viewModel)
 {
     var question = await _questions.FirstAsync(a => a.Id == viewModel.Id);
     _mappingEngine.Map(viewModel, question);
     question.LasModifierId = _userManager.GetCurrentUserId();
 }