public string addExpenditure(string expenditureJson) { try { //创建service层实例 investmentService = new InvestmentService(); //处理json InvestmentExpenditure investmentExpenditure = FinanceJson.getFinanceJson().toObject <InvestmentExpenditure>(expenditureJson); if (investmentService.addInvestmentExpenditure(investmentExpenditure)) { 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 <InvestmentExpenditure> getInvestmentExpenditureList(FinancePage <InvestmentExpenditure> financePage) { InvestmentExpenditure investmentExpenditure = new InvestmentExpenditure(); //获取pageList financePage = commonModel.getComList <InvestmentExpenditure>(investmentExpenditure, financePage, account.company, "investmentExpenditure"); //获取总行数 financePage.total = commonModel.getComTotal <InvestmentExpenditure>(investmentExpenditure, account.company, "investmentExpenditure"); return(financePage); }
/// <summary> /// 删除 /// </summary> /// <param name="ids">id数组</param> /// <returns>删除是否成功</returns> public Boolean deleteInvestmentExpenditure(int[] ids) { InvestmentExpenditure investmentExpenditure = new InvestmentExpenditure(); for (int i = 0; i < ids.Length; i++) { investmentExpenditure = commonModel.comFind <InvestmentExpenditure>(investmentExpenditure, ids[i]); if (commonModel.comDel <InvestmentExpenditure>(investmentExpenditure) <= 0) { return(false); } } return(true); }
/// <summary> /// 修改 /// </summary> /// <param name="financingExpenditure"></param> /// <returns></returns> public Boolean updateInvestmentExpenditure(InvestmentExpenditure investmentExpenditure) { investmentExpenditure.company = account.company; return(commonModel.comUpd <InvestmentExpenditure>(investmentExpenditure) > 0); }