public async Task <ActionResult> Edit([Bind(Include = "Id,DistributorId,PostTitle,PostMessage,MediaType,OriginalMediaLink,ThumbnailLink")] PostViewModel postViewModel) { if (!ModelState.IsValid) { return(Json(new { success = false, Response = "", Error = ErrorHelper.GetModelStateErrorMessages(ModelState) }, JsonRequestBehavior.AllowGet)); } var errorMessage = ""; var distributor = new Distributor(); if (!IdentityHelper.TryGetDistributor(User, out distributor, out errorMessage)) { return(Json(new { success = false, Response = "", Error = errorMessage }, JsonRequestBehavior.AllowGet)); } try { _postAdapter.Update(postViewModel, distributor); return(Json(new { success = true, Response = postViewModel, Error = "" }, JsonRequestBehavior.AllowGet)); } catch (Exception exception) { return(Json(new { success = false, Response = "", Error = exception.Message }, JsonRequestBehavior.AllowGet)); } }
public ActionResult Edit(PostViewModel postViewModel) { if (!ModelState.IsValid) { return(new JsonResult(new { success = false, Response = "", Error = ErrorHelper.GetModelStateErrorMessages(ModelState) })); } if (!_identityHelper.TryGetDistributor(out Distributor distributor, out string errorMessage)) { return(new JsonResult(new { success = false, Response = "", Error = errorMessage })); } try { _postAdapter.Update(postViewModel, distributor); return(new JsonResult(new { success = true, Response = postViewModel, Error = "" })); } catch (Exception exception) { return(new JsonResult(new { success = false, Response = "", Error = exception.Message })); } }