public IActionResult Post([FromBody] Loan loan) { if (loan == null) { return(BadRequest("Loan is null")); } if (loanManager.Add(loan) == 1) { return(Ok(true)); } else { return(BadRequest(false)); } }
public void AddLoan_Group_MinimumValues() { _loan.ClientType = OClientTypes.Group; _loan.LoanShares = new List <LoanShare> { new LoanShare { PersonId = 2, Amount = 1000 } }; _loan.Id = _loanManager.Add(_loan, 1); Assert.AreNotEqual(0, _loan.Id); }
public int Add(Project pProject, int pTiersId, SqlTransaction pSqlTransac) { const string q = @"INSERT INTO Projects([tiers_id],[status],[name],[code],[aim],[begin_date], [abilities],[experience],[market],[concurrence],[purpose],[corporate_name],[corporate_juridicStatus] ,[corporate_FiscalStatus],[corporate_siret],[corporate_CA],[corporate_nbOfJobs],[corporate_financialPlanType] ,[corporateFinancialPlanAmount],[corporate_financialPlanTotalAmount],[address],[city],[zipCode],[district_id] ,[home_phone],[personalPhone],[Email],[hometype],[corporate_registre]) VALUES(@tiersId,@status,@name,@code,@aim,@beginDate,@abilities,@experience,@market,@concurrence,@purpose, @corporateName,@corporateJuridicStatus,@corporateFiscalStatus,@corporateSiret,@corporateCA,@corporateNbOfJobs, @corporateFinancialPlanType, @corporateFinancialPlanAmount, @corporateFinancialPlanTotalAmount, @address,@city, @zipCode, @districtId, @homePhone, @personalPhone,@Email,@hometype,@corporateRegistre) SELECT SCOPE_IDENTITY()"; using (OpenCbsCommand c = new OpenCbsCommand(q, pSqlTransac.Connection, pSqlTransac)) { c.AddParam("@tiersId", pTiersId); c.AddParam("@status", (int)pProject.ProjectStatus); c.AddParam("@name", pProject.Name); c.AddParam("@code", pProject.Code); c.AddParam("@aim", pProject.Aim); c.AddParam("@beginDate", pProject.BeginDate); c.AddParam("@abilities", pProject.Abilities); c.AddParam("@experience", pProject.Experience); c.AddParam("@market", pProject.Market); c.AddParam("@concurrence", pProject.Concurrence); c.AddParam("@purpose", pProject.Purpose); c.AddParam("@corporateName", pProject.CorporateName); c.AddParam("@corporateJuridicStatus", pProject.CorporateJuridicStatus); c.AddParam("@corporateFiscalStatus", pProject.CorporateFiscalStatus); c.AddParam("@corporateRegistre", pProject.CorporateRegistre); c.AddParam("@corporateSiret", pProject.CorporateSIRET); c.AddParam("@corporateCA", pProject.CorporateCA); c.AddParam("@corporateNbOfJobs", pProject.CorporateNbOfJobs); c.AddParam("@corporateFinancialPlanType", pProject.CorporateFinancialPlanType); c.AddParam("@corporateFinancialPlanAmount", pProject.CorporateFinancialPlanAmount); c.AddParam("@corporateFinancialPlanTotalAmount", pProject.CorporateFinancialPlanTotalAmount); c.AddParam("@address", pProject.Address); c.AddParam("@city", pProject.City); c.AddParam("@zipCode", pProject.ZipCode); if (pProject.District != null) { c.AddParam("@districtId", pProject.District.Id); } else { c.AddParam("@districtId", null); } c.AddParam("@homePhone", pProject.HomePhone); c.AddParam("@personalPhone", pProject.PersonalPhone); c.AddParam("@Email", pProject.Email); c.AddParam("@hometype", pProject.HomeType); pProject.Id = Convert.ToInt32(c.ExecuteScalar()); } foreach (FollowUp followUp in pProject.FollowUps) { _AddFollowUp(followUp, pProject.Id, pSqlTransac); } foreach (Loan credit in pProject.Credits) { _creditManager.Add(credit, pProject.Id, pSqlTransac); } return(pProject.Id); }