public bool Registrar(Comprobante comprobante) { try { using (var context = new FacturadorContext()) { context.Entry(comprobante).State = EntityState.Added; context.SaveChanges(); } } catch (Exception) { return false; } return true; }
public Comprobante ToModel() { var comprobante = new Comprobante(); comprobante.Cliente = this.Cliente; comprobante.Creado = DateTime.Now; comprobante.Total = this.Total(); foreach(var d in ComprobanteDetalle) { comprobante.ComprobanteDetalle.Add(new ComprobanteDetalle { ProductoId = d.ProductoId, Monto = d.Monto(), PrecioUnitario = d.PrecioUnitario, Cantidad = d.Cantidad }); } return comprobante; }