public string Delete(int id)
        {
            var cliente = this.access.clientes.Find(id);

            if (cliente.facturas.Count > 0)
            {
                return(this.serializer.Serialize(new { success = false, error = "Existen facturas asociadas a este cliente" }));
            }
            access.clientes.Remove(cliente);
            access.SaveChanges();
            return(this.serializer.Serialize(new { success = true }));
        }
Beispiel #2
0
        public string Save(FacturaViewModel facture)
        {
            if (!ModelState.IsValid)
            {
                IEnumerable <ModelError> errores = ModelState.Values.SelectMany(v => v.Errors);
                return(serializer.Serialize(new { success = false, errores = errores }));
            }

            factura factura = new factura()
            {
                cliente_id = facture.cliente.Value
            };

            foreach (var producto in facture.productos)
            {
                factura.productos_factura.Add(new productos_factura()
                {
                    productos_id   = producto.id.Value,
                    cantidad       = producto.cantidad.Value,
                    valor_unitario = producto.valor.Value
                });
            }

            access.facturas.Add(factura);
            access.SaveChanges();
            return(serializer.Serialize(new { success = true }));
        }
Beispiel #3
0
        public string Delete(string id)
        {
            var        empleado = this.access.empleados.Find(id);
            AspNetUser user     = empleado.AspNetUser;

            access.empleados.Remove(empleado);
            access.AspNetUsers.Remove(user);
            access.SaveChanges();
            return(this.serializer.Serialize(new { success = true }));
        }
        public string Delete(int id)
        {
            var productos = this.access.productos.Find(id);

            if (productos.productos_factura.Count > 0)
            {
                return(this.serializer.Serialize(new { success = false, error = "Existen facturas asociadas a este producto" }));
            }
            access.productos.Remove(productos);
            access.SaveChanges();
            return(this.serializer.Serialize(new { success = true }));
        }