public ActionResult Edit(TbInventario empEdit)
 {
     try
     {
         var context     = HttpContext.RequestServices.GetService(typeof(rodlpContext)) as rodlpContext;
         var objectEdit  = context.TbInventario.FirstOrDefault(em => em.IdInventario == empEdit.IdInventario);
         var currentUser = HttpContext.Session.GetString("nomUsuario");
         if (objectEdit != null)
         {
             objectEdit.Matricula   = empEdit.Matricula;
             objectEdit.Cantidad    = empEdit.Cantidad;
             objectEdit.Empresa     = empEdit.Empresa;
             objectEdit.Nombre      = empEdit.Nombre;
             objectEdit.ParaFactura = empEdit.ParaFactura;
             objectEdit.Vendedor    = empEdit.Vendedor;
             context.TbInventario.Update(empEdit);
             context.SaveChanges();
         }
         return(RedirectToAction(nameof(Index)));
     }
     catch
     {
         return(View());
     }
 }
示例#2
0
        public async Task <IActionResult> PutTbInventario(int id, TbInventario tbInventario)
        {
            if (id != tbInventario.CodInventario)
            {
                return(BadRequest());
            }

            _context.Entry(tbInventario).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!TbInventarioExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
示例#3
0
        public async Task <ActionResult <TbInventario> > PostTbInventario(TbInventario tbInventario)
        {
            TbInventario reg = new TbInventario();

            reg.EstadoActivo     = tbInventario.EstadoActivo;
            reg.NombreInventario = tbInventario.NombreInventario;
            _context.TbInventario.Add(reg);
            await _context.SaveChangesAsync();


            return(CreatedAtAction("GetTbInventario", new { id = reg.CodInventario }, reg));
        }
 public ActionResult Create(TbInventario ti)
 {
     try
     {
         var context = HttpContext.RequestServices.GetService(typeof(rodlpContext)) as rodlpContext;
         ti.Estado = 1;
         context.TbInventario.Add(ti);
         context.SaveChanges();
         return(RedirectToAction(nameof(Index)));
     }
     catch (Exception e)
     {
         return(Content("" + e));
     }
 }