public bool UpdatePostAndReplyJoin(PostAndReplyJoinEdit model) { var entity = _dbContext.PostAndReplyJoins .Single(x => x.JoinID == model.JoinID); // && x.ReplyCreator == _userID); entity.Post.PostContent = model.PostContent; entity.Reply.ReplyContent = model.ReplyContent; // May add in future //entity.ModifiedUtc = DateTimeOffset.UtcNow; return(_dbContext.SaveChanges() == 1); }
// GET: /Post/Edit/{id} public ActionResult Edit(int id) { var service = CreatePostAndReplyJoinService(); var detail = service.GetPostAndReplyJoinByID(id); var model = new PostAndReplyJoinEdit { JoinID = detail.JoinID, PostContent = detail.PostContent, ReplyContent = detail.ReplyContent }; //return View(model); if (service.ValidateUser(id) == true) { return(View(model)); } return(View("ValidationFailed")); }
public ActionResult Edit(int id, PostAndReplyJoinEdit model) { if (!ModelState.IsValid) { return(View(model)); } if (model.JoinID != id) { ModelState.AddModelError("", "ID Mismatch"); return(View(model)); } var service = CreatePostAndReplyJoinService(); if (service.UpdatePostAndReplyJoin(model)) { TempData["SaveResult"] = "Your join was updated."; return(RedirectToAction("Index")); } ModelState.AddModelError("", "Your join could not be updated."); return(View(model)); }