예제 #1
0
        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 }));
            }
        }
예제 #2
0
        // 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));
            }
        }