public ActionResult Create(ContentTypeViewModel model) { try { if (ModelState.IsValid) { SetRequestURL(APIURL.CONTENT_TYPE_INSERT, Method.POST); request.AddBody(model); var response = rest.Execute(request); if (response.StatusCode == HttpStatusCode.OK) { long _id = JsonConvert.DeserializeObject<long>(response.Content); SetMessage(Message.SuccessfulCreate(model.name), MESSAGE_TYPE.SUCCESS); return RedirectToAction("Details", new { id = _id }); } else { ModelState.AddModelError("", response.Content); } } } catch (Exception ex) { ModelState.AddModelError("", ex.Message); } SetTitle("Create Content Type"); return View(model); }
public ActionResult Edit(ContentTypeViewModel model) { try { if (ModelState.IsValid) { SetRequestURL(APIURL.CONTENT_TYPE_UPDATE, Method.POST); request.AddBody(model); var response = rest.Execute(request); if (response.StatusCode == HttpStatusCode.OK) { SetMessage(Message.SuccessfulUpdate(model.name), MESSAGE_TYPE.SUCCESS); return RedirectToAction("Details", new { id = model.id }); } else { ModelState.AddModelError("", response.Content); } } } catch (Exception ex) { ModelState.AddModelError("", ex.Message); } SetTitle("Edit - " + model.name); return View(model); }