Exemplo n.º 1
0
        public static bool EditarProducto(Producto producto)
        {
            bool response = false;

            try
            {
                using (var dbContextScope = new DBFacturacionEntities())
                {
                    var productoExistente = dbContextScope.Producto.Where(x => x.Id == producto.Id).FirstOrDefault();
                    if (productoExistente != null)
                    {
                        productoExistente.NombreProducto = !string.IsNullOrEmpty(producto.NombreProducto) ? producto.NombreProducto : productoExistente.NombreProducto;
                        productoExistente.Precio         = producto.Precio != null ? producto.Precio : productoExistente.Precio;
                        productoExistente.Inventario     = producto.Inventario != null ? producto.Inventario : productoExistente.Inventario;

                        dbContextScope.SaveChanges();
                        response = true;
                    }
                }
            }
            catch (Exception ex)
            {
                response = false;
                throw ex;
            }

            return(response);
        }
Exemplo n.º 2
0
        public static bool EliminarProducto(Producto producto)
        {
            bool response = false;

            try
            {
                using (var dbContextScope = new DBFacturacionEntities())
                {
                    var productobuscado = dbContextScope.Producto.Where(x => x.Id == producto.Id).FirstOrDefault();
                    if (productobuscado != null)
                    {
                        dbContextScope.Producto.Remove(productobuscado);
                        dbContextScope.SaveChanges();
                        response = true;
                    }
                }
            }
            catch (Exception ex)
            {
                response = false;
                throw ex;
            }

            return(response);
        }
Exemplo n.º 3
0
        public static bool EditarCompra(Compra compra)
        {
            bool response = false;

            try
            {
                using (var dbContextScope = new DBFacturacionEntities())
                {
                    var CompraExistente = dbContextScope.Compra.Where(x => x.Id == compra.Id).FirstOrDefault();
                    if (CompraExistente != null)
                    {
                        CompraExistente.ClienteId = compra.ClienteId != null ? compra.ClienteId : CompraExistente.ClienteId;

                        dbContextScope.SaveChanges();
                        response = true;
                    }
                }
            }
            catch (Exception ex)
            {
                response = false;
                throw ex;
            }

            return(response);
        }
Exemplo n.º 4
0
        public static bool EliminarCompra(Compra compra)
        {
            bool response = false;

            try
            {
                using (var dbContextScope = new DBFacturacionEntities())
                {
                    var comprabuscado = dbContextScope.Compra.Where(x => x.Id == compra.Id).FirstOrDefault();
                    if (comprabuscado != null)
                    {
                        dbContextScope.Compra.Remove(comprabuscado);
                        dbContextScope.SaveChanges();
                        response = true;
                    }
                }
            }
            catch (Exception ex)
            {
                response = false;
                throw ex;
            }

            return(response);
        }
Exemplo n.º 5
0
        public static bool EditarCliente(Cliente cliente)
        {
            bool response = false;

            try
            {
                using (var dbContextScope = new DBFacturacionEntities())
                {
                    var clienteExistente = dbContextScope.Cliente.Where(x => x.Id == cliente.Id).FirstOrDefault();
                    if (clienteExistente != null)
                    {
                        clienteExistente.Edad   = cliente.Edad != null ? cliente.Edad : clienteExistente.Edad;
                        clienteExistente.Nombre = !string.IsNullOrEmpty(cliente.Nombre) ? cliente.Nombre : clienteExistente.Nombre;

                        dbContextScope.SaveChanges();
                        response = true;
                    }
                }
            }
            catch (Exception ex)
            {
                response = false;
                throw ex;
            }

            return(response);
        }
Exemplo n.º 6
0
        public static bool EditarCompraProducto(CompraProducto compraProducto)
        {
            bool response = false;

            try
            {
                using (var dbContextScope = new DBFacturacionEntities())
                {
                    var CompraProductoExistente = dbContextScope.CompraProducto.Where(x => x.Id == compraProducto.Id).FirstOrDefault();
                    if (CompraProductoExistente != null)
                    {
                        CompraProductoExistente.CompraId      = compraProducto.CompraId != null ? compraProducto.CompraId : CompraProductoExistente.CompraId;
                        CompraProductoExistente.ProductoId    = compraProducto.ProductoId != null ? compraProducto.ProductoId : CompraProductoExistente.ProductoId;
                        CompraProductoExistente.Cantidad      = compraProducto.Cantidad != null ? compraProducto.Cantidad : CompraProductoExistente.Cantidad;
                        CompraProductoExistente.ValorProducto = compraProducto.ValorProducto != null ? compraProducto.ValorProducto : CompraProductoExistente.ValorProducto;
                        CompraProductoExistente.FechaCompra   = compraProducto.FechaCompra != null ? compraProducto.FechaCompra : CompraProductoExistente.FechaCompra;

                        dbContextScope.SaveChanges();
                        response = true;
                    }
                }
            }
            catch (Exception ex)
            {
                response = false;
                throw ex;
            }

            return(response);
        }
Exemplo n.º 7
0
 public static List <Producto> ObtenerProductos()
 {
     try
     {
         using (var dbContextScope = new DBFacturacionEntities())
         {
             return(dbContextScope.Producto.ToList());
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 8
0
 public static List <Compras> ObtenerComprasSP()
 {
     try
     {
         using (var dbContextScope = new DBFacturacionEntities())
         {
             return(dbContextScope.ObtenerCompras().ToList());
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 9
0
 public static List <Cliente> ObtenerClientes()
 {
     try
     {
         using (var dbContextScope = new DBFacturacionEntities())
         {
             return(dbContextScope.Cliente.ToList());
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 10
0
        public static bool CrearProducto(Producto Producto)
        {
            bool response = false;

            try
            {
                using (var dbContextScope = new DBFacturacionEntities())
                {
                    dbContextScope.Producto.Add(Producto);
                    dbContextScope.SaveChanges();
                    response = true;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(response);
        }
Exemplo n.º 11
0
        public static bool CrearCompra(Compra compra)
        {
            bool response = false;

            try
            {
                using (var dbContextScope = new DBFacturacionEntities())
                {
                    dbContextScope.Compra.Add(compra);
                    dbContextScope.SaveChanges();
                    response = true;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(response);
        }