public async Task <ActionResult <RepoOrder> > PostRepoOrder(RepoOrder repoOrder) { _context.RepoOrders.Add(repoOrder); await _context.SaveChangesAsync(); return(CreatedAtAction("GetRepoOrder", new { id = repoOrder.Id }, repoOrder)); }
public async Task <ActionResult <RepoOrder> > PostRepoOrder(decimal amount, DateTime maturity, decimal interestRate, long customerId, long dealerId) { RepoCalculator repoCalculator = new RepoCalculator(amount, maturity, interestRate); RepoOrder repoOrder = new RepoOrder() { Amount = repoCalculator.GetAmount(), CustomerId = customerId, DealerId = dealerId, GrossInterestAmount = repoCalculator.GetGrossInterestAmount(), InterestRate = repoCalculator.GetInterestRate(), GrossInterestRate = repoCalculator.GetGrossInterestRate(), Maturity = repoCalculator.GetMaturityDate(), NetInterestAmount = repoCalculator.GetNetInterestAmount(), OrderStatus = OrderStatus.Waiting, ReturnGrossInterestAmount = repoCalculator.GetReturnGrossAmount(), ReturnNetInterestAmount = repoCalculator.GetReturnNetAmount(), StartDate = DateTime.Now, TaxAmount = repoCalculator.GetTaxAmount() }; _context.RepoOrders.Add(repoOrder); await _context.SaveChangesAsync(); return(CreatedAtAction("GetRepoOrder", new { id = repoOrder.Id }, repoOrder)); }
public async Task <IActionResult> PutRepoOrder(long id, RepoOrder repoOrder) { if (id != repoOrder.Id) { return(BadRequest()); } _context.Entry(repoOrder).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!RepoOrderExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }