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 UpdateFieldStatus(int id, string field, int included) { if (!AuthorizationProvider.CanEditRevenue()) { return(Forbidden()); } try { var provider = new OtherRevenueProvider(_dbContext); var ok = provider.SetFieldStatus(id, field, (included == 1 ? true : false)); if (ok) { return(Json(id, JsonRequestBehavior.AllowGet)); } else { return(Json(string.Empty, JsonRequestBehavior.AllowGet)); } } catch (Exception ex) { string message = string.Format("Change Other Revenue 'IncludeInStatement' for ID = {0:d} fails. {1}", id, ex.Message + ex.StackTrace); return(InternalError(message, string.Empty, ex)); } }
public JsonResult Retrieve(DateTime month, string propertyCode) { if (!AuthorizationProvider.CanViewRevenue()) { return(Forbidden()); } var provider = new OtherRevenueProvider(_dbContext); var view = provider.Retrieve(month, propertyCode); return(Json(view, JsonRequestBehavior.AllowGet)); }
public JsonResult UpdateWorkflow(int id, int state, int direction) { if (!AuthorizationProvider.CanEditRevenue()) { return(Forbidden()); } RevenueApprovalStatus workflowState = (RevenueApprovalStatus)state; if (!((AuthorizationProvider.CanReviewRevenue() && workflowState == RevenueApprovalStatus.Reviewed) || (AuthorizationProvider.CanApproveRevenue() && workflowState == RevenueApprovalStatus.Approved) || (AuthorizationProvider.CanFinalizeRevenue() && workflowState == RevenueApprovalStatus.Finalized))) { return(Forbidden()); } try { var dataProvider = new OtherRevenueProvider(_dbContext); RevenueApprovalStatus?nextState = null; if (direction > 0) { nextState = dataProvider.MoveWorkflow(id, workflowState); } else { nextState = dataProvider.BacktrackWorkflow(id, workflowState); } if (nextState != null) { return(Json(nextState, JsonRequestBehavior.AllowGet)); } else { return(Json("-1", JsonRequestBehavior.AllowGet)); } } catch (Exception ex) { string message = string.Format("Change Other Expense {0} workflow fails. {1}", id.ToString(), ex.Message + ex.StackTrace); return(InternalError(message, "-1", 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)); } }