public async Task <ErrorCodeLib.Models.ResultModel> PUT([FromBody] ExpenditureModel model) { var result = new ErrorCodeLib.Models.ResultModel(); if (model.id == null) { result = ErrorCode.PARAMETER_REQUIRED(new string[] { "id" }, "cht"); return(result); } //檢查expenditure var exist_expenditure = _repo_expenditure.FindById(Convert.ToInt32(model.id)); if (exist_expenditure == null) { result = ErrorCode.DB_ERROR_NOT_FOUND(null, "id", "cht"); return(result); } //檢查project var exist_project = _repo_project.FindById(Convert.ToInt32(model.project_id)); if (exist_project == null) { result = ErrorCode.DB_ERROR_NOT_FOUND(null, "project_id", "cht"); return(result); } //檢查partner var exist_partner = _repo_partner.FindById(Convert.ToInt32(model.partner_id)); if (exist_partner == null) { result = ErrorCode.DB_ERROR_NOT_FOUND(null, "partner_id", "cht"); return(result); } //檢查item var exist_item = _repo_item.FindById(Convert.ToInt32(model.item_id)); if (exist_item == null) { result = ErrorCode.DB_ERROR_NOT_FOUND(null, "item_id", "cht"); return(result); } model.updated = DateTime.Now; _repo_expenditure.Update(model); var exception_save = _unitOfWork.Save(); if (exception_save != null) { result = ErrorCode.CUSTOM_ERROR(exception_save.Message, "DB ERROR", 500, "cht"); } result = ErrorCode.SUCCESS(null, "修改成功", "cht"); return(result); }