public JsonResult Index() { if (!_identityHelper.TryGetDistributor(out Distributor distributor, out string errorMessage)) { return(new JsonResult(new { success = false, Response = "", Error = errorMessage })); } try { var postsList = _postAdapter.List(distributor); return(new JsonResult(new { success = true, Response = postsList })); } catch (Exception exception) { return(new JsonResult(new { success = false, Response = "", Error = exception.Message })); } }
// GET: Posts public JsonResult Index() { 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 { var postsList = _postAdapter.List(distributor); return(Json(new { success = true, Response = postsList }, JsonRequestBehavior.AllowGet)); } catch (Exception exception) { return(Json(new { success = false, Response = "", Error = exception.Message }, JsonRequestBehavior.AllowGet)); } }