public async Task <IActionResult> PutCrediario(int id, Crediario crediario) { if (id != crediario.IdCrediario) { return(BadRequest()); } _context.Entry(crediario).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CrediarioExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public virtual Crediario SaveCrediario(CrediarioViewModel modelView) { try { Crediario entity = new Crediario { PersonId = modelView.PersonId, UserId = modelView.UserId, EnableCrediario = modelView.EnableCrediario }; _rep.Insert(entity); if (modelView.Sales != null && modelView.Sales.Count() > 0) { modelView.Sales.ToList().ForEach(x => _appSale.SaveSale(new SaleViewModel { Value = x.Value, EnableSale = x.EnableSale, PurchaseDate = x.PurchaseDate, CreadiarioId = entity.Id })); } return(entity); } catch (Exception ex) { throw new ValidationException(); } }
public async Task <ActionResult <Crediario> > PostCrediario(Crediario crediario) { _context.Crediario.Add(crediario); await _context.SaveChangesAsync(); return(CreatedAtAction("GetCrediario", new { id = crediario.IdCrediario }, crediario)); }
public void TaxarOValorFinal() { const double TAXA_CREDIARIO = 0.015; var valorEsperado = 1000 * (1 + TAXA_CREDIARIO); var crediario = new Crediario(1000, 12, lista); Assert.Equal(valorEsperado, crediario.ValorFinal()); }
public void DeleteCrediario(int id) { Crediario crediario = _rep.Get(id); if (crediario != null) { _rep.Delete(crediario); } }
public void DeleteCrediario(int id) { Crediario crediario = _rep.Get(id); if (crediario != null) { crediario.EnableCrediario = false; _rep.Update(crediario); } }
public virtual Crediario EditCrediario(CrediarioViewModel view) { try { //List<Sale> sale = new List<Sale>(); //for (int i = 0; i < view.Sales.Count(); i++) //{ // sale.Add(new Sale // { // Id = (int)view.Sales[i]?.Id.Value, // CreadiarioId = (int)view?.Sales[i]?.CreadiarioId, // EnableSale = view.Sales[i].EnableSale, // PurchaseDate = view.Sales[i].PurchaseDate, // Value = view.Sales[i].Value // }); //} Crediario crediario = _rep.Get(view.Id.Value); if (crediario != null) { crediario.PersonId = view.PersonId; crediario.UserId = view.UserId; _rep.Update(crediario); } if (view.Sales != null && view.Sales.Count() > 0) { view.Sales.ToList().ForEach(x => _appSale.EditSale(new SaleViewModel { Id = x.Id, Value = x.Value, EnableSale = x.EnableSale, PurchaseDate = x.PurchaseDate, CreadiarioId = crediario.Id })); } return(crediario); } catch (Exception ex) { throw ex; } }
public virtual Crediario GetById(int id) { try { var entity = _rep.Get(id); Crediario crediario = new Crediario { Id = entity.Id, PersonId = entity.PersonId, UserId = entity.UserId, Sales = entity.Sales }; return(crediario); } catch (Exception ex) { throw ex; } }
public virtual Crediario EditCrediario(CrediarioViewModel view) { try { Crediario crediario = _rep.Get(view.Id.Value); if (crediario != null) { crediario.PersonId = view.PersonId; crediario.Rate = view.Rate; crediario.Sales = view.Sales; crediario.UserId = view.UserId; crediario.SchedulingPayment = view.SchedulingPayment; _rep.Update(crediario); } return(crediario); } catch (Exception ex) { throw ex; } }
public void IdExistente() { var crediario = new Crediario(1000.0, 1, lista); Assert.True(crediario.IdTransacao > 0); }
public void LimitarAsParcelas() { Crediario crediario; Assert.Throws <ArgumentException>(() => crediario = new Crediario(1000, 25, lista)); }