Ejemplo n.º 1
0
        public string Delete(long IDProduct, long IDRecipe)
        {
            try
            {
                using (var context = new ProyectoMaestriaEntities())
                {
                    var result = context.Ingredient.SingleOrDefault(x => x.IDProduct == IDProduct && x.IDRecipe == IDRecipe);
                    if (result != null)
                    {
                        context.Ingredient.Remove(result);
                        context.SaveChanges();
                        return("Registro eliminado satisfactroriamente");
                    }
                    else
                    {
                        return("no se ha encontrado el registro a eliminar");
                    }
                }
            }

            catch (Exception e)
            {
                return(e.Message);
            }
        }
Ejemplo n.º 2
0
        public string DeleteById(long Id)
        {
            try
            {
                using (var context = new ProyectoMaestriaEntities())
                {
                    var result = context.OrderItem.Where(x => x.ID == Id).ToList();
                    if (result != null)
                    {
                        foreach (var temp in result)
                        {
                            context.OrderItem.Remove(temp);
                            context.SaveChanges();
                        }
                        return("Registro eliminado satisfactroriamente");
                    }
                    else
                    {
                        return("no se ha encontrado el registro a eliminar");
                    }
                }
            }

            catch (Exception e)
            {
                return(e.Message);
            }
        }
Ejemplo n.º 3
0
        public string Insertar(Ingredient ingredient)
        {
            int result;

            try
            {
                using (var context = new ProyectoMaestriaEntities())
                {
                    var repetido = context.Ingredient.SingleOrDefault(x => x.IDProduct == ingredient.IDProduct && x.IDRecipe == ingredient.IDRecipe);
                    if (repetido == null)
                    {
                        var std = new Ingredient()
                        {
                            //public long ID { get; set; }
                            //       public string Username { get; set; }
                            //       public string Password { get; set; }
                            //       public string Name { get; set; }
                            //       public string LastName { get; set; }
                            //       public string UserType { get; set; }
                            //                    //       public Nullable<long> ProviderID { get; set; }
                            //              public Nullable<long> IDRecipe { get; set; }
                            //public Nullable<long> IDProduct { get; set; }
                            //public Nullable<int> Quantity { get; set; }
                            IDRecipe  = ingredient.IDRecipe,
                            IDProduct = ingredient.IDProduct,
                            Quantity  = ingredient.Quantity
                        };

                        context.Ingredient.Add(std);

                        result = context.SaveChanges();
                        if (result == 0)
                        {
                            return("no se ha podido ingresar el registro");
                        }
                        else
                        {
                            return(std.Id.ToString());
                        }
                    }
                    else
                    {
                        return("el registro ya se encuentra en la base de datos");
                    }
                }
            }
            catch (Exception e)
            {
                return(e.Message);
            }
        }
Ejemplo n.º 4
0
        public string InsertarComedor(DiningRoom comedor)
        {
            int result;

            try
            {
                using (var context = new ProyectoMaestriaEntities())
                {
                    var repetido = context.DiningRoom.SingleOrDefault(x => x.Code == comedor.Code);
                    if (repetido == null)
                    {
                        var std = new DiningRoom()
                        {
                            //    ID = comedor.ID,
                            Code              = comedor.Code,
                            Name              = comedor.Name,
                            Address           = comedor.Address,
                            Phone             = comedor.Phone,
                            Email             = comedor.Email,
                            Neiborhood        = comedor.Neiborhood,
                            City              = comedor.City,
                            Contact           = comedor.Contact,
                            ContactEmail      = comedor.ContactEmail,
                            ContactPhone      = comedor.ContactPhone,
                            ChildNumber       = comedor.ChildNumber,
                            ScheduleReception = comedor.ScheduleReception
                        };
                        context.DiningRoom.Add(std);

                        result = context.SaveChanges();
                        if (result == 0)
                        {
                            return("no se ha podido ingresar el registro");
                        }
                        else
                        {
                            return(std.ID.ToString());
                        }
                    }
                    else
                    {
                        return("el registro ya se encuentra en la base de datos");
                    }
                }
            }
            catch (Exception e)
            {
                return(e.Message);
            }
        }
Ejemplo n.º 5
0
        public string Insert(Disponibility disponibility)
        {
            int result;

            try
            {
                using (var context = new ProyectoMaestriaEntities())
                {
                    var repetido = context.Disponibility.SingleOrDefault(x => x.ID == disponibility.ID);
                    if (repetido == null)
                    {
                        var std = new Disponibility()
                        {
                            //                     public Nullable<long> IDProvider { get; set; }
                            //public long ID { get; set; }
                            //public Nullable<long> IDProduct { get; set; }
                            //public Nullable<int> Quantity { get; set; }
                            //public Nullable<decimal> UnitValue { get; set; }
                            //public Nullable<System.DateTime> ExpirationDate { get; set; }

                            //    ID = comedor.ID,
                            IDProduct      = disponibility.IDProduct,
                            IDProvider     = disponibility.IDProvider,
                            Quantity       = disponibility.Quantity,
                            UnitValue      = disponibility.UnitValue,
                            ExpirationDate = disponibility.ExpirationDate
                        };
                        context.Disponibility.Add(std);

                        result = context.SaveChanges();
                        if (result == 0)
                        {
                            return("no se ha podido ingresar el registro");
                        }
                        else
                        {
                            return(std.ID.ToString());
                        }
                    }
                    else
                    {
                        return("el registro ya se encuentra en la base de datos");
                    }
                }
            }
            catch (Exception e)
            {
                return(e.Message);
            }
        }
Ejemplo n.º 6
0
        public string Insertar(SystemUser systemUser)
        {
            int result;

            try
            {
                using (var context = new ProyectoMaestriaEntities())
                {
                    var repetido = context.SystemUser.SingleOrDefault(x => x.Username == systemUser.Name);
                    if (repetido == null)
                    {
                        var std = new SystemUser()
                        {
                            //public long ID { get; set; }
                            //       public string Username { get; set; }
                            //       public string Password { get; set; }
                            //       public string Name { get; set; }
                            //       public string LastName { get; set; }
                            //       public string UserType { get; set; }
                            //       public Nullable<long> ProviderID { get; set; }
                            Username   = systemUser.Username,
                            Password   = systemUser.Password,
                            Name       = systemUser.Name,
                            LastName   = systemUser.LastName,
                            UserType   = systemUser.UserType,
                            ProviderID = systemUser.ProviderID
                        };
                        context.SystemUser.Add(std);

                        result = context.SaveChanges();
                        if (result == 0)
                        {
                            return("no se ha podido ingresar el registro");
                        }
                        else
                        {
                            return(std.ID.ToString());
                        }
                    }
                    else
                    {
                        return("el registro ya se encuentra en la base de datos");
                    }
                }
            }
            catch (Exception e)
            {
                return(e.Message);
            }
        }
Ejemplo n.º 7
0
        public string UpdateOrderItem(OrderItem orderItem)
        {
            int modify = 0;

            try
            {
                using (var context = new ProyectoMaestriaEntities())
                {
                    var result = context.OrderItem.SingleOrDefault(b => b.ID == orderItem.ID);
                    if (result != null)
                    {
                        result.IDPreOrder        = orderItem.IDPreOrder;
                        result.IDProduct         = orderItem.IDProduct;
                        result.IDProvider        = orderItem.IDProvider;
                        result.IDTransport       = orderItem.IDTransport;
                        result.Quantity          = orderItem.Quantity;
                        result.UnitValue         = orderItem.UnitValue;
                        result.ExpirationDays    = orderItem.ExpirationDays;
                        result.Cost              = orderItem.Cost;
                        result.DurationText      = orderItem.DurationText;
                        result.DistanceText      = orderItem.DistanceText;
                        result.CostTransport     = orderItem.CostTransport;
                        result.Total             = orderItem.Total;
                        result.AcceptedProvider  = orderItem.AcceptedProvider;
                        result.AcceptedTransport = orderItem.AcceptedTransport;
                        result.TimeOrderItem     = orderItem.TimeOrderItem;


                        modify = context.SaveChanges();
                        if (modify == 0)
                        {
                            return("no se ha podido modificar el registro");
                        }
                        else
                        {
                            return("se ha modificado el registro satisfactoriamente");
                        }
                    }
                    else
                    {
                        return("no se ha encontrado coincidencia en la base de datos");
                    }
                }
            }

            catch (Exception e)
            {
                return(e.Message);
            }
        }
Ejemplo n.º 8
0
        public string Update(SystemUser systemuser)
        {
            int modify = 0;

            try
            {
                using (var context = new ProyectoMaestriaEntities())
                {
                    var result = context.SystemUser.SingleOrDefault(b => b.ID == systemuser.ID);
                    if (result != null)
                    {
                        //public long ID { get; set; }
                        //       public string Username { get; set; }
                        //       public string Password { get; set; }
                        //       public string Name { get; set; }
                        //       public string LastName { get; set; }
                        //       public string UserType { get; set; }
                        //       public Nullable<long> ProviderID { get; set; }
                        result.Password = systemuser.Password;
                        result.Name     = systemuser.Name;

                        result.LastName   = systemuser.LastName;
                        result.UserType   = systemuser.UserType;
                        result.ProviderID = systemuser.ProviderID;



                        modify = context.SaveChanges();
                        if (modify == 0)
                        {
                            return("no se ha podido modificar el registro");
                        }
                        else
                        {
                            return("se ha modificado el registro satisfactoriamente");
                        }
                    }
                    else
                    {
                        return("no se ha encontrado coincidencia en la base de datos");
                    }
                }
            }

            catch (Exception e)
            {
                return(e.Message);
            }
        }
Ejemplo n.º 9
0
        public string Modify(Transport transport)
        {
            int modify = 0;

            try
            {
                using (var context = new ProyectoMaestriaEntities())
                {
                    var result = context.Transport.SingleOrDefault(b => b.ID == transport.ID);
                    if (result != null)
                    {
                        result.Code                = transport.Code;
                        result.CarPlate            = transport.CarPlate;
                        result.Brand               = transport.Brand;
                        result.Year                = transport.Year;
                        result.PersonInCharge      = transport.PersonInCharge;
                        result.PhonePersonInCharge = transport.PhonePersonInCharge;
                        result.MailPersonInCharge  = transport.MailPersonInCharge;
                        result.PaymentUnity        = transport.PaymentUnity;
                        result.PaymentMeasurement  = transport.PaymentMeasurement;
                        result.PaymentValue        = transport.PaymentValue;
                        result.Availability        = transport.Availability;
                        result.TransportType       = transport.TransportType;
                        result.IDProvider          = transport.IDProvider;


                        modify = context.SaveChanges();
                        if (modify == 0)
                        {
                            return("no se ha podido modificar el registro");
                        }
                        else
                        {
                            return("se ha modificado el registro satisfactoriamente");
                        }
                    }
                    else
                    {
                        return("no se ha encontrado coincidencia en la base de datos");
                    }
                }
            }

            catch (Exception e)
            {
                return(e.Message);
            }
        }
Ejemplo n.º 10
0
        public string Update(Ingredient ingredient)
        {
            int modify = 0;

            try
            {
                using (var context = new ProyectoMaestriaEntities())
                {
                    var result = context.Ingredient.SingleOrDefault(x => x.Id == ingredient.Id);
                    if (result != null)
                    {
                        //public long ID { get; set; }
                        //       public string Username { get; set; }
                        //       public string Password { get; set; }
                        //       public string Name { get; set; }
                        //       public string LastName { get; set; }
                        //       public string UserType { get; set; }
                        //       public Nullable<long> ProviderID { get; set; }
                        result.IDProduct = ingredient.IDProduct;
                        result.IDRecipe  = ingredient.IDRecipe;

                        result.Quantity = ingredient.Quantity;



                        modify = context.SaveChanges();
                        if (modify == 0)
                        {
                            return("no se ha podido modificar el registro");
                        }
                        else
                        {
                            return("se ha modificado el registro satisfactoriamente");
                        }
                    }
                    else
                    {
                        return("no se ha encontrado coincidencia en la base de datos");
                    }
                }
            }

            catch (Exception e)
            {
                return(e.Message);
            }
        }
Ejemplo n.º 11
0
        public string UpdateDinner(DiningRoom comedor)
        {
            int modify = 0;

            try
            {
                using (var context = new ProyectoMaestriaEntities())
                {
                    var result = context.DiningRoom.SingleOrDefault(b => b.ID == comedor.ID);
                    if (result != null)
                    {
                        result.Code              = comedor.Code;
                        result.Name              = comedor.Name;
                        result.Address           = comedor.Address;
                        result.Phone             = comedor.Phone;
                        result.Email             = comedor.Email;
                        result.Neiborhood        = comedor.Neiborhood;
                        result.City              = comedor.City;
                        result.Contact           = comedor.Contact;
                        result.ContactEmail      = comedor.ContactEmail;
                        result.ContactPhone      = comedor.ContactPhone;
                        result.ChildNumber       = comedor.ChildNumber;
                        result.ScheduleReception = comedor.ScheduleReception;


                        modify = context.SaveChanges();
                        if (modify == 0)
                        {
                            return("no se ha podido modificar el registro");
                        }
                        else
                        {
                            return("se ha modificado el registro satisfactoriamente");
                        }
                    }
                    else
                    {
                        return("no se ha encontrado coincidencia en la base de datos");
                    }
                }
            }

            catch (Exception e)
            {
                return(e.Message);
            }
        }
Ejemplo n.º 12
0
        public string InsertOrderItem(OrderItem orderItem)
        {
            int result;

            try
            {
                using (var context = new ProyectoMaestriaEntities())
                {
                    var std = new OrderItem()
                    {
                        //    ID = orderItem.ID;
                        IDPreOrder        = orderItem.IDPreOrder,
                        IDProduct         = orderItem.IDProduct,
                        IDProvider        = orderItem.IDProvider,
                        IDTransport       = orderItem.IDTransport,
                        Quantity          = orderItem.Quantity,
                        UnitValue         = orderItem.UnitValue,
                        ExpirationDays    = orderItem.ExpirationDays,
                        Cost              = orderItem.Cost,
                        DurationText      = orderItem.DurationText,
                        DistanceText      = orderItem.DistanceText,
                        CostTransport     = orderItem.CostTransport,
                        Total             = orderItem.Total,
                        AcceptedProvider  = orderItem.AcceptedProvider,
                        AcceptedTransport = orderItem.AcceptedTransport,
                        TimeOrderItem     = orderItem.TimeOrderItem
                    };
                    context.OrderItem.Add(std);

                    result = context.SaveChanges();
                    if (result == 0)
                    {
                        return("no se ha podido ingresar el registro");
                    }
                    else
                    {
                        return(std.ID.ToString());
                    }
                }
            }
            catch (Exception e)
            {
                return(e.Message);
            }
        }
Ejemplo n.º 13
0
        public string InsertarProducto(Product product)
        {
            int result;

            try
            {
                using (var context = new ProyectoMaestriaEntities())
                {
                    var repetido = context.Product.SingleOrDefault(x => x.Code == product.Code);
                    if (repetido == null)
                    {
                        var std = new Product()
                        {
                            //    ID = comedor.ID,
                            Code            = product.Code,
                            Name            = product.Name,
                            Description     = product.Description,
                            Preservation    = product.Preservation,
                            MeasurementUnit = product.MeasurementUnit,
                            ProductType     = product.ProductType
                        };
                        context.Product.Add(std);

                        result = context.SaveChanges();
                        if (result == 0)
                        {
                            return("no se ha podido ingresar el registro");
                        }
                        else
                        {
                            return(std.ID.ToString());
                        }
                    }
                    else
                    {
                        return("el registro ya se encuentra en la base de datos");
                    }
                }
            }
            catch (Exception e)
            {
                return(e.Message);
            }
        }
Ejemplo n.º 14
0
        public string Update(Product producto)
        {
            int modify = 0;

            try
            {
                using (var context = new ProyectoMaestriaEntities())
                {
                    var result = context.Product.SingleOrDefault(b => b.ID == producto.ID);
                    if (result != null)
                    {
                        result.Code            = producto.Code;
                        result.Name            = producto.Name;
                        result.Description     = producto.Description;
                        result.Preservation    = producto.Preservation;
                        result.MeasurementUnit = producto.MeasurementUnit;
                        result.ProductType     = producto.ProductType;
                        //  result.Disponibility = producto.Disponibility;


                        modify = context.SaveChanges();
                        if (modify == 0)
                        {
                            return("no se ha podido modificar el registro");
                        }
                        else
                        {
                            return("se ha modificado el registro satisfactoriamente");
                        }
                    }
                    else
                    {
                        return("no se ha encontrado coincidencia en la base de datos");
                    }
                }
            }

            catch (Exception e)
            {
                return(e.Message);
            }
        }
Ejemplo n.º 15
0
        public string Insertar(Recipe recipe)
        {
            int result;

            try
            {
                using (var context = new ProyectoMaestriaEntities())
                {
                    var repetido = context.Recipe.SingleOrDefault(x => x.Code == recipe.Code);
                    if (repetido == null)
                    {
                        var std = new Recipe()
                        {
                            //    ID = comedor.ID,
                            Code = recipe.Code,
                            Name = recipe.Name
                        };
                        context.Recipe.Add(std);

                        result = context.SaveChanges();
                        if (result == 0)
                        {
                            return("no se ha podido ingresar el registro");
                        }
                        else
                        {
                            return(std.ID.ToString());
                        }
                    }
                    else
                    {
                        return("el registro ya se encuentra en la base de datos");
                    }
                }
            }
            catch (Exception e)
            {
                return(e.Message);
            }
        }
Ejemplo n.º 16
0
        public string InsertList(List <PreOrderItem> items)
        {
            int result = 0;

            try
            {
                using (var context = new ProyectoMaestriaEntities())
                {
                    foreach (PreOrderItem poi in items)
                    {
                        var std = new PreOrderItem
                        {
                            //  ID=poi.ID,
                            IDProduct  = poi.IDProduct,
                            IDPreOrder = poi.IDPreOrder,
                            Quantity   = poi.Quantity
                        };
                        context.PreOrderItem.Add(std);

                        result = context.SaveChanges();
                        if (result == 0)
                        {
                            return("no se ha podido ingresar el registro");
                        }
                        else
                        {
                            result = int.Parse(std.ID.ToString());
                        }
                    }

                    return(result.ToString());
                }
            }
            catch (Exception e)
            {
                return(e.Message);
            }
        }
Ejemplo n.º 17
0
        public string Update(Disponibility disponibility)
        {
            int modify = 0;

            try
            {
                using (var context = new ProyectoMaestriaEntities())
                {
                    var result = context.Disponibility.SingleOrDefault(b => b.ID == disponibility.ID);
                    if (result != null)
                    {
                        result.IDProvider     = disponibility.IDProvider;
                        result.Quantity       = disponibility.Quantity;
                        result.UnitValue      = disponibility.UnitValue;
                        result.IDProduct      = disponibility.IDProduct;
                        result.ExpirationDate = disponibility.ExpirationDate;
                        modify = context.SaveChanges();
                        if (modify == 0)
                        {
                            return("no se ha podido modificar el registro");
                        }
                        else
                        {
                            return("se ha modificado el registro satisfactoriamente");
                        }
                    }
                    else
                    {
                        return("no se ha encontrado coincidencia en la base de datos");
                    }
                }
            }

            catch (Exception e)
            {
                return(e.Message);
            }
        }
Ejemplo n.º 18
0
        public bool InsertarComedor(Comedor comedor)
        {
            int result;

            using (var context = new ProyectoMaestriaEntities())
            {
                var std = new Comedor()
                {
                    Codigo               = comedor.Codigo,
                    Nombre               = comedor.Nombre,
                    Direccion            = comedor.Direccion,
                    Telefono             = comedor.Telefono,
                    Email                = comedor.Email,
                    Pais                 = comedor.Pais,
                    Departamento         = comedor.Departamento,
                    Ciudad               = comedor.Ciudad,
                    Contacto             = comedor.Contacto,
                    Email_Contacto       = comedor.Email_Contacto,
                    Telefono_Contacto    = comedor.Telefono_Contacto,
                    Numero_Niños         = comedor.Numero_Niños,
                    ZonaHorarioRecepción = comedor.ZonaHorarioRecepción
                };
                context.Comedor.Add(std);

                result = context.SaveChanges();

                if (result == 0)
                {
                    return(false);
                }
                else
                {
                    return(true);
                }
            }
        }