public ActionResult Index(int id = 0) { if (id == 0) { AddSubscriptionPackageBindingModel model = new AddSubscriptionPackageBindingModel(); model.DurationTypeOptions = Utility.GetDurationTypeOptions(); model.SetSharedData(User); return(View(model)); } else { var response = AsyncHelpers.RunSync <JObject>(() => ApiCall.CallApi("/api/Admin/GetEntityById", User, null, true, false, null, "Id=" + id + "&EntityType=2")); AddSubscriptionPackageBindingModel model = new AddSubscriptionPackageBindingModel(); if (response is Error) { return(new HttpStatusCodeResult(HttpStatusCode.InternalServerError, "Internal Server Error")); } else { model = response.GetValue("result").ToObject <AddSubscriptionPackageBindingModel>(); } model.DurationTypeOptions = Utility.GetDurationTypeOptions(); model.SetSharedData(User); return(View(model)); } }
public async Task <ActionResult> AddSubscription(AddSubscriptionPackageBindingModel model) { if (ModelState.IsValid) { JObject response; response = await ApiCall.CallApi("api/Admin/AddSubscriptionPackage", User, model); if (response.ToString().Contains("UnAuthorized")) { return(new HttpStatusCodeResult(HttpStatusCode.Unauthorized, "UnAuthorized Error")); } else if (response is Error) { return(new HttpStatusCodeResult(HttpStatusCode.InternalServerError, (response as Error).ErrorMessage)); } return(RedirectToAction("ManageSubscriptions", "SubscriptionPackages")); } else { return(View()); } }