// GET: Campaigns/Details/5
        public async Task <JsonResult> Details(int?id)
        {
            if (id == null)
            {
                throw new ArgumentNullException("Id");
            }

            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 campaign = _campaignAdapter.GetById(id.Value, distributor);
                return(Json(new { success = true, Response = campaign }, JsonRequestBehavior.AllowGet));
            }
            catch (Exception exception)
            {
                return(Json(new { success = false, Response = "", Error = exception.Message }, JsonRequestBehavior.AllowGet));
            }
        }
Beispiel #2
0
        public JsonResult Details(int?id)
        {
            if (id == null)
            {
                throw new ArgumentNullException("Id");
            }

            if (!_identityHelper.TryGetDistributor(out Distributor distributor, out string errorMessage))
            {
                return(new JsonResult(new { success = false, Response = "", Error = errorMessage }));
            }

            try
            {
                var campaign = _campaignAdapter.GetById(id.Value, distributor);
                return(new JsonResult(new { success = true, Response = campaign }));
            }
            catch (Exception exception)
            {
                return(new JsonResult(new { success = false, Response = "", Error = exception.Message }));
            }
        }