Exemplo n.º 1
0
        public static void AddDB(ProductoModel modelo, TipoPrecioToProduct modeloTipoPrecio)
        {
            using (efooddatabaseEntities db = new efooddatabaseEntities())
            {
                try
                {
                    string codigoDeProducto = ConsecutivoModel.GetConsecutivo("Productos");
                    //Entidades de la base de datos
                    Product product = new Product
                    {
                        ProductCode        = codigoDeProducto,
                        ProductDescription = modelo.ProductDescription,
                        FoodOptionCode     = modelo.FoodOptionCode,
                        ProductContent     = modelo.ProductContent,
                        ProductImage       = modelo.ProductImage
                    };
                    db.Products.Add(product);
                    db.SaveChanges();

                    PriceTypeToProduct priceToProduct = new PriceTypeToProduct
                    {
                        PriceTypeCode = modeloTipoPrecio.PriceTypeCode,
                        ProductCode   = codigoDeProducto,
                        Price         = modeloTipoPrecio.Price
                    };

                    db.PriceTypeToProducts.Add(priceToProduct);
                    db.SaveChanges();
                    BitacoraModel.AddLogBook("a", "Anadir", Admin.ObtenerIdUsuario());
                }
                catch (Exception e) { ErrorLogModel.AddError(e); }
            }
        }
        public static void AddLogBook(string tipo, string description, int userID)
        {
            using (efooddatabaseEntities db = new efooddatabaseEntities())
            {
                try
                {   //Entidades de la base de datos
                    LogBook log = new LogBook();

                    //Toda la data de la base de datos, se almacena en la lista numeroConsecutivo
                    var numeroConsecutivo = (from valor in db.LogBooks
                                             select valor);

                    //Primary key
                    int code = numeroConsecutivo.Count() + 1;

                    log.LogID       = code;
                    log.UserID      = userID;
                    log.LogDate     = DateTime.Now;
                    log.RegCode     = ConsecutivoModel.GetConsecutivo("Bitacoras");
                    log.LogType     = tipo;
                    log.Description = description;
                    log.RegDetails  = "N/A";
                    //log.User = Admin.ObtenerUsuarioUnico(userID);
                    db.LogBooks.Add(log);
                    db.SaveChanges();
                }
                catch (Exception e) { ErrorLogModel.AddError(e); }
            }
        }
Exemplo n.º 3
0
 public static void AddDB(LineaComidaModel modelo)
 {
     using (efooddatabaseEntities db = new efooddatabaseEntities())
     {
         try
         {   //Entidades de la base de datos
             FoodOption foodOption = new FoodOption
             {
                 FoodOptionCode        = ConsecutivoModel.GetConsecutivo("Líneas de comida"),
                 FoodOptionDescription = modelo.FoodOptionDescription
             };
             db.FoodOptions.Add(foodOption);
             db.SaveChanges();
             BitacoraModel.AddLogBook("a", "Anadir", Admin.ObtenerIdUsuario());
         }
         catch (Exception e) { ErrorLogModel.AddError(e); }
     }
 }
 public static void AddDB(TipoPrecioModelo modelo)
 {
     using (efooddatabaseEntities db = new efooddatabaseEntities())
     {
         try
         {   //Entidades de la base de datos
             PriceType priceType = new PriceType
             {
                 PriceTypeCode        = ConsecutivoModel.GetConsecutivo("Precios"),
                 PriceTypeDescription = modelo.PriceTypeDescription
             };
             db.PriceTypes.Add(priceType);
             db.SaveChanges();
             BitacoraModel.AddLogBook("a", "Anadir", Admin.ObtenerIdUsuario());
         }
         catch (Exception e) { ErrorLogModel.AddError(e); }
     }
 }
 public static void AddDB(TarjetaCreditoDebitoModel modelo)
 {
     using (efooddatabaseEntities db = new efooddatabaseEntities())
     {
         try
         {   //Entidades de la base de datos
             Card newCard = new Card
             {
                 CardCode        = ConsecutivoModel.GetConsecutivo("Tarjetas"),
                 CardDescription = modelo.CardDescription
             };
             db.Cards.Add(newCard);
             db.SaveChanges();
             BitacoraModel.AddLogBook("a", "Anadir", Admin.ObtenerIdUsuario());
         }
         catch (Exception e) { ErrorLogModel.AddError(e); }
     }
 }
 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); }
     }
 }
Exemplo n.º 7
0
 public static void AddDB(MediosPagoModel modelo)
 {
     using (efooddatabaseEntities db = new efooddatabaseEntities())
     {
         try
         {   //Entidades de la base de datos
             PaymentProcessor newProcessor = new PaymentProcessor
             {
                 PaymentProcessorCode        = ConsecutivoModel.GetConsecutivo("Medios de pago"),
                 PaymentProcessorName        = modelo.PaymentProcessorName,
                 PaymentProcessorDescription = modelo.PaymentProcessorDescription,
                 PaymentProcessorType        = modelo.PaymentProcessorType,
                 PaymentProcessorMethod      = modelo.PaymentProcessorMethod,
                 PaymentProcessorStatus      = false,
                 PaymentProcessorVerify      = false
             };
             db.PaymentProcessors.Add(newProcessor);
             db.SaveChanges();
             BitacoraModel.AddLogBook("a", "Anadir", Admin.ObtenerIdUsuario());
         }
         catch (Exception e) { ErrorLogModel.AddError(e); }
     }
 }