public static void DeletetDB(TiqueteDescuentoModel modelo) { try { using (efooddatabaseEntities db = new efooddatabaseEntities()) { var datos = (from valor in db.TicketDiscounts where valor.TicketCode == modelo.TicketCode select valor).SingleOrDefault(); db.TicketDiscounts.Remove(datos); db.SaveChanges(); BitacoraModel.AddLogBook("n", "Borrar", Admin.ObtenerIdUsuario()); } } catch (Exception x) { ErrorLogModel.AddError(x); } }
public static void EditDB(TiqueteDescuentoModel modelo) { try { using (efooddatabaseEntities db = new efooddatabaseEntities()) { var datos = (from valor in db.TicketDiscounts where valor.TicketCode == modelo.TicketCode select valor).SingleOrDefault(); datos.TicketDescription = modelo.TicketDescription; datos.TicketDiscountPercentage = modelo.TicketDiscountPercentage; datos.RemainingTickets = modelo.RemainingTickets; db.SaveChanges(); BitacoraModel.AddLogBook("e", "Edicion", Admin.ObtenerIdUsuario()); } } catch (Exception x) { ErrorLogModel.AddError(x); } }
public static void AddDB(TiqueteDescuentoModel modelo) { using (efooddatabaseEntities db = new efooddatabaseEntities()) { try { //Entidades de la base de datos TicketDiscount newTicketDiscount = new TicketDiscount { TicketCode = ConsecutivoModel.GetConsecutivo("Tiquetes de descuento"), TicketDescription = modelo.TicketDescription, TicketDiscountPercentage = modelo.TicketDiscountPercentage, RemainingTickets = modelo.RemainingTickets }; db.TicketDiscounts.Add(newTicketDiscount); db.SaveChanges(); BitacoraModel.AddLogBook("a", "Anadir", Admin.ObtenerIdUsuario()); } catch (Exception e) { ErrorLogModel.AddError(e); } } }