Пример #1
0
 public ActionResult Create(int id, int answerId, string description, string parentId, AuthenticatedUser user, HttpPostedFileBase file)
 {
     int pid = Convert.ToInt16(parentId);
     bool isRoot;
     if (parentId == "0")
     {
         isRoot = true;
     }
     else
     {
         isRoot = false;
     }
     string finalPath = Helpers.SaveFile(file, Server, "comments/"+id.ToString()+"/");
     int newCommentId = Service.FactorCommentAdd(id, user.UserEntity, answerId, description, pid, finalPath);
     FactorCommentEntity comment = new FactorCommentEntity()
     {
         FactorCommentId = newCommentId,
         FactorId = answerId,
         Comment = description,
         DateCreated = System.DateTime.Now,
         UserId = user.UserEntity.Id,
         User = user.UserEntity,
         Path = finalPath
     };
     CommentViewModel model = new CommentViewModel()
     {
         Comment = comment,
         User = user.UserEntity,
         IsRoot = isRoot
     };
     return View("Comment", model);
 }
Пример #2
0
 public ActionResult Edit(int id, int commentId, string description, HttpPostedFileBase file, string fileModified = "0", string originalPath = "")
 {
     string path;
     if (fileModified != "0") //modified
     {
         path = Helpers.SaveFile(file, Server, "comments/"+id.ToString()+"/"); //returns empty string if file is null/no file uploaded
     }
     else
     {
         path = originalPath;
     }
     Service.FactorCommentUpdate(id, commentId, description, path);
     CommentViewModel model = new CommentViewModel
     {
         NewPath = path
     }; //sharing the same view, passing in same model
     return View("Comment", model);
 }