public ActionResult Create(CategoryModel categoryModel) { try { if (categoryModel.Name != null || categoryModel.Picture != null) { if (ModelState.IsValid) { var category = Newtonsoft.Json.JsonConvert.SerializeObject(categoryModel); if (category != null) { var response = _handler.Post(category); if (response.StatusCode == 201) { //At this time do nothing _log.Debug("Answer from Web API: " + response.StatusCode + response.StatusDescription); } } } return RedirectToAction("Index"); } _log.Debug("No 'Navn' or 'Billede' added to new category, exiting"); return RedirectToAction("Index"); } catch (Exception ex) { _log.Exception(ex.Message + ex.InnerException); return RedirectToAction("Index"); } }
public ActionResult Edit(CategoryModel categoryModel) { try { if (ModelState.IsValid) { var category = Newtonsoft.Json.JsonConvert.SerializeObject(categoryModel); var response = _handler.Put(category); if (response.StatusCode == 202) { //At this time do nothing _log.Debug("Answer from Web API: " + response.StatusCode + response.StatusDescription); } } return RedirectToAction("Index"); } catch(Exception ex) { _log.Exception(ex.Message + ex.InnerException); return RedirectToAction("Index"); } }