public JsonResult Update(string model) { if (!AuthorizationProvider.CanEditRevenue()) { return(Forbidden()); } // parameter is passed in as a model with Json string var entity = JsonConvert.DeserializeObject <OtherRevenueModel>(model); try { var dataProvider = new OtherRevenueProvider(_dbContext); dataProvider.Update(entity.OtherRevenueId, entity); dataProvider.Commit(); return(Json(entity, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { var innerErrorMessage = ex.InnerException != null ? ex.InnerException.Message : string.Empty; string message = string.Format("Saving Other Expense {0:d} fails. {1} - {2}", entity.OtherRevenueId, ex.Message, innerErrorMessage); return(InternalError(message, "fail", ex)); } }
public JsonResult Delete(string model) { if (!AuthorizationProvider.CanEditRevenue()) { return(Forbidden()); } // parameter is passed in as a model with Json string var entity = JsonConvert.DeserializeObject <OtherRevenueModel>(model); try { var dataProvider = new OtherRevenueProvider(_dbContext); dataProvider.Delete(entity.OtherRevenueId); dataProvider.Commit(); return(Json("success", JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(InternalError(string.Format("Delete Other Expense {0:d} fails.", entity.OtherRevenueId), "fail", ex)); } }