Exemplo n.º 1
0
 public Response <Client> Save(Client client)
 {
     try {
         context.Add(client);
         context.SaveChanges();
         return(new Response <Client>(client));
     } catch (Exception e) {
         return(new Response <Client>($"Error del aplicacion: {e.Message}"));
     }
 }
Exemplo n.º 2
0
 public Response <Client> save(Client client)
 {
     try
     {
         client.Person.Status = true;
         _context.Clients.Add(client);
         _context.SaveChanges();
         return(new Response <Client>(client));
     }
     catch (System.Exception error)
     {
         return(new Response <Client>("Error:" + error));
     }
 }
Exemplo n.º 3
0
 public Response <Product> save(Product product)
 {
     try
     {
         _context.Products.Add(product);
         _context.SaveChanges();
         return(new Response <Product>(product));
     }
     catch (System.Exception error)
     {
         return(new Response <Product>("Error:" + error));
     }
 }
Exemplo n.º 4
0
 public Response <Presentation> save(Presentation presentation)
 {
     try
     {
         _context.Presentations.Add(presentation);
         _context.SaveChanges();
         return(new Response <Presentation>(presentation));
     }
     catch (System.Exception error)
     {
         return(new Response <Presentation>("Error:" + error));
     }
 }
Exemplo n.º 5
0
 public Response <Category> save(Category category)
 {
     try
     {
         _context.Categories.Add(category);
         _context.SaveChanges();
         return(new Response <Category>(category));
     }
     catch (System.Exception error)
     {
         return(new Response <Category>("Error:" + error));
     }
 }
Exemplo n.º 6
0
 public Response <Invoice> Save(Invoice invoice)
 {
     try {
         Invoice newInvoice = new Invoice(invoice.Client);
         foreach (InvoiceDetail detail in invoice.InvoiceDetails)
         {
             if (detail.Product.QuantityStock - detail.QuantityProduct < 0)
             {
                 return(new Response <Invoice>("No hay suficiente stock"));
             }
             newInvoice.AddInvoiceDetails(detail.Product, detail.QuantityProduct, detail.Discount, detail.UnitValue);
             detail.Product.discountQuantityStock(detail.QuantityProduct);
             _context.Products.Update(detail.Product);
         }
         newInvoice.CalculateTotal();
         _context.Invoices.Add(newInvoice);
         _context.SaveChanges();
         return(new Response <Invoice>(newInvoice));
     } catch (Exception e) {
         return(new Response <Invoice>($"Error del aplicacion: {e.Message}"));
     }
 }