Beispiel #1
0
 public ActionResult Edit(CloseQuestionFullViewModel model)
 {
     if (!ModelState.IsValid || model.Content == null || OtherFunctions.IsHasJS(model.Content))
     {
         string errors = "";
         if (model.Content != null && OtherFunctions.IsHasJS(model.Content))
         {
             errors += Common.FiledQDanger + "<br/>";
         }
         if (model.Content == null)
         {
             errors += Common.FieldQRequired + "<br/>";
         }
         if (model.Points == 0)
         {
             errors += (Common.ShouldBeNum + " <br/>");
         }
         TempData["EditErrors"] = errors;
         return(Redirect("/CloseQuestion/Question/" + model.Id));
     }
     this.closeQuestionService.Update(new CloseQuestion
     {
         Content  = model.Content,
         Points   = model.Points,
         Id       = model.Id,
         HelpLink = model.HelpLink
     });
     return(Redirect("/CloseQuestion/Question/" + model.Id));
 }
Beispiel #2
0
 public ActionResult Question(int id)
 {
     if (BellongToCurrentUserQ(id, this.User.Identity.GetUserId()))
     {
         var question  = this.closeQuestionService.GetById(id);
         var viewModel = new CloseQuestionFullViewModel
         {
             Content  = question.Content,
             Images   = this.cloudinaryService.AddPathToQuestionImageName(question.Images).ToList(),
             Points   = question.Points,
             Topic    = question.Topic,
             Id       = question.Id,
             Answers  = question.Answers.ToList(),
             HelpLink = question.HelpLink
         };
         foreach (var item in viewModel.Answers)
         {
             item.Images = this.cloudinaryService.AddPathToQuestionImageName(item.Images).ToList();
         }
         return(View(viewModel));
     }
     return(Redirect("/"));
 }