예제 #1
0
        //[ValidateAntiForgeryToken]
        public async Task <JsonResult> DeleteConfirmed(int?id)
        {
            if (id == null)
            {
                return(Json(new { success = false, Response = "", Error = "Id is null, please provide it in the request." }, 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
            {
                _campaignAdapter.Delete(id.Value, distributor);

                return(Json(new { success = true, Response = "", Error = "" }, JsonRequestBehavior.AllowGet));
            }
            catch (Exception exception)
            {
                return(Json(new { success = false, Response = "", Error = exception.Message }, JsonRequestBehavior.AllowGet));
            }
        }
예제 #2
0
        public JsonResult DeleteConfirmed(int?id)
        {
            if (id == null)
            {
                return(new JsonResult(new { success = false, Response = "", Error = "Id is null, please provide it in the request." }));
            }

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

            try
            {
                _campaignAdapter.Delete(id.Value, distributor);

                return(new JsonResult(new { success = true, Response = "", Error = "" }));
            }
            catch (Exception exception)
            {
                return(new JsonResult(new { success = false, Response = "", Error = exception.Message }));
            }
        }