public string addExpenditure(string expenditureJson) { try { //创建service层实例 financingService = new FinancingService(); //处理json FinancingExpenditure financingExpenditure = FinanceJson.getFinanceJson().toObject <FinancingExpenditure>(expenditureJson); if (financingService.addFinancingExpenditure(financingExpenditure)) { return(FinanceResultData.getFinanceResultData().success(200, null, "新增成功")); } else { return(FinanceResultData.getFinanceResultData().fail(500, null, "新增失败")); } } catch (InvalidOperationException ex) { //身份验证不通过 return(FinanceResultData.getFinanceResultData().fail(401, null, ex.Message)); } catch (Exception ex) { //未知的错误 return(FinanceResultData.getFinanceResultData().fail(500, null, "未知的错误")); } }
/// <summary> /// 获取分页对象的pageList和总页数 /// </summary> /// <param name="financePage">分页对象</param> /// <returns>处理过的分页对象</returns> public FinancePage <FinancingExpenditure> getFinancingExpenditureList(FinancePage <FinancingExpenditure> financePage) { FinancingExpenditure financingExpenditure = new FinancingExpenditure(); //获取pageList financePage = commonModel.getComList <FinancingExpenditure>(financingExpenditure, financePage, account.company, "financingExpenditure"); //获取总行数 financePage.total = commonModel.getComTotal <FinancingExpenditure>(financingExpenditure, account.company, "financingExpenditure"); return(financePage); }
/// <summary> /// 删除 /// </summary> /// <param name="ids">id数组</param> /// <returns>删除是否成功</returns> public Boolean deleteFinancingExpenditure(int[] ids) { FinancingExpenditure financingExpenditure = new FinancingExpenditure(); for (int i = 0; i < ids.Length; i++) { financingExpenditure = commonModel.comFind <FinancingExpenditure>(financingExpenditure, ids[i]); if (commonModel.comDel <FinancingExpenditure>(financingExpenditure) <= 0) { return(false); } } return(true); }
/// <summary> /// 修改 /// </summary> /// <param name="financingExpenditure"></param> /// <returns></returns> public Boolean updateFinancingExpenditure(FinancingExpenditure financingExpenditure) { financingExpenditure.company = account.company; return(commonModel.comUpd <FinancingExpenditure>(financingExpenditure) > 0); }