コード例 #1
0
 public IEnumerable <Producto> Get()
 {
     using (var context = new MiTiendaContext())
     {
         return(context.Productos.ToList());
     }
 }
コード例 #2
0
 public Producto Get(int id)
 {
     using (var context = new MiTiendaContext())
     {
         return(context.Productos.FirstOrDefault(x => x.Id == id));
     }
 }
コード例 #3
0
 public Cliente Get(string Nombres)
 {
     using (var context = new MiTiendaContext())
     {
         return(context.Clientes.FirstOrDefault(x => x.Nombres == Nombres));
     }
 }
コード例 #4
0
 public IEnumerable <Cliente> Get()
 {
     using (var context = new MiTiendaContext())
     {
         return(context.Clientes.ToList());
     }
 }
コード例 #5
0
 public Producto Post(Producto producto)
 {
     using (var context = new MiTiendaContext())
     {
         context.Productos.Add(producto);
         context.SaveChanges();
         return(producto);
     }
 }
コード例 #6
0
 public Cliente Post(Cliente cliente)
 {
     using (var context = new MiTiendaContext())
     {
         context.Clientes.Add(cliente);
         context.SaveChanges();
         return(cliente);
     }
 }
コード例 #7
0
 public bool Delete(int id)
 {
     using (var context = new MiTiendaContext())
     {
         var productoDel = context.Productos.FirstOrDefault(x => x.Id == id);
         context.Productos.Remove(productoDel);
         context.SaveChanges();
         return(true);
     }
 }
コード例 #8
0
 public bool Delete(string Nombres)
 {
     using (var context = new MiTiendaContext())
     {
         var clienteDel = context.Clientes.FirstOrDefault(x => x.Nombres == Nombres);
         context.Clientes.Remove(clienteDel);
         context.SaveChanges();
         return(true);
     }
 }
コード例 #9
0
        public Producto Put(Producto producto)
        {
            using (var context = new MiTiendaContext())
            {
                var productoAct = context.Productos.FirstOrDefault(x => x.Id == producto.Id);
                productoAct.Cantidad    = producto.Cantidad;
                productoAct.Descripcion = producto.Descripcion;
                productoAct.Nombre      = producto.Nombre;
                productoAct.Imagen      = producto.Imagen;

                context.SaveChanges();
                return(producto);
            }
        }
コード例 #10
0
 public Cliente Put(Cliente cliente)
 {
     using (var context = new MiTiendaContext())
     {
         var clienteAct = context.Clientes.FirstOrDefault(x => x.id == cliente.id);
         clienteAct.Nombres         = cliente.Nombres;
         clienteAct.apellidos       = cliente.apellidos;
         clienteAct.Direccion       = cliente.Direccion;
         clienteAct.Celular         = cliente.Celular;
         clienteAct.Estracto        = cliente.Estracto;
         clienteAct.FechaNacimiento = cliente.FechaNacimiento;
         context.SaveChanges();
         return(cliente);
     }
 }