예제 #1
0
 public ActionResult Edit(TbFactura empEdit)
 {
     try
     {
         var context     = HttpContext.RequestServices.GetService(typeof(rodlpContext)) as rodlpContext;
         var objectEdit  = context.TbFactura.FirstOrDefault(em => em.IdFactura == empEdit.IdFactura);
         var currentUser = HttpContext.Session.GetString("nomUsuario");
         if (objectEdit != null)
         {
             objectEdit.Nombre    = empEdit.Nombre;
             objectEdit.Apellidos = empEdit.Apellidos;
             objectEdit.Cantidad  = empEdit.Cantidad;
             objectEdit.Emisor    = empEdit.Emisor;
             objectEdit.Fecha     = empEdit.Fecha;
             objectEdit.Precio    = empEdit.Precio;
             objectEdit.Rfc       = empEdit.Rfc;
             context.TbFactura.Update(objectEdit);
             context.SaveChanges();
         }
         return(RedirectToAction(nameof(Index)));
     }
     catch
     {
         return(View());
     }
 }
예제 #2
0
 public ActionResult Create(TbFactura tf)
 {
     try
     {
         var currentUser = HttpContext.Session.GetString("nomUsuario");
         var context     = HttpContext.RequestServices.GetService(typeof(rodlpContext)) as rodlpContext;
         context.TbFactura.Add(tf);
         context.SaveChanges();
         return(RedirectToAction(nameof(Index)));
     }
     catch
     {
         return(View());
     }
 }