Ejemplo n.º 1
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.º 2
0
        public List <Recipe> GetRecomendedRecipes(int countChildren)
        {
            List <Recipe> recipes = new List <Recipe>();

            using (var context = new ProyectoMaestriaEntities())
            {
                var result = (
                    from R in context.Recipe
                    join I in context.Ingredient on R.ID equals I.IDRecipe
                    join D in context.Disponibility on I.IDProduct equals D.IDProduct
                    where D.Quantity >= countChildren
                    group R by new { R.Code, R.ID, R.Name } into g
                    select new
                {
                    ID = g.Key.ID,
                    Code = g.Key.Code,
                    Name = g.Key.Name,
                }).ToList();



                if (result != null)
                {
                    foreach (var temp in result)
                    {
                        Recipe recipe = new Recipe();
                        recipe.ID   = temp.ID;
                        recipe.Code = temp.Code;
                        recipe.Name = temp.Name;
                        recipes.Add(recipe);
                    }

                    return(recipes);
                }
                else
                {
                    return(recipes);
                }
            }
        }
Ejemplo n.º 3
0
 public Transport Extract(string code)
 {
     using (var context = new ProyectoMaestriaEntities())
     {
         // Query for all blogs with names starting with B
         //var ComedorExtracted = from b in context.Comedor
         //            where b.ID.Equals(id)
         //            select b;
         var transport = context.Transport.SingleOrDefault(x => x.Code == code);
         if (transport != null)
         {
             return(new Transport
             {
                 ID = transport.ID,
                 Code = transport.Code,
                 CarPlate = transport.CarPlate,
                 Brand = transport.Brand,
                 Year = transport.Year,
                 PersonInCharge = transport.PersonInCharge,
                 PhonePersonInCharge = transport.PhonePersonInCharge,
                 MailPersonInCharge = transport.MailPersonInCharge,
                 PaymentUnity = transport.PaymentUnity,
                 PaymentMeasurement = transport.PaymentMeasurement,
                 PaymentValue = transport.PaymentValue,
                 Availability = transport.Availability,
                 TransportType = transport.TransportType,
                 IDProvider = transport.IDProvider
             });
         }
         else
         {
             return(null);
         }
         //// Query for the Blog named ADO.NET Blog
         //var blog = context.Blogs
         //                .Where(b => b.Name == "ADO.NET Blog")
         //                .FirstOrDefault();
     }
 }
Ejemplo n.º 4
0
        public string Update(Recipe producto)
        {
            int modify = 0;

            try
            {
                using (var context = new ProyectoMaestriaEntities())
                {
                    var result = context.Recipe.SingleOrDefault(b => b.ID == producto.ID);
                    if (result != null)
                    {
                        result.Code = producto.Code;
                        result.Name = producto.Name;

                        //  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.º 5
0
        public List <Provider> ExtractAllProviders()
        {
            List <Provider> Providers = new List <Provider>();

            using (var context = new ProyectoMaestriaEntities())
            {
                var result = context.Provider.ToList();


                if (result != null)
                {
                    foreach (var temp in result)
                    {
                        Provider provider = new Provider();
                        provider.ID = temp.ID;

                        provider.Code           = temp.Code;
                        provider.Name           = temp.Name;
                        provider.Address        = temp.Address;
                        provider.Neiborhood     = temp.Neiborhood;
                        provider.City           = temp.City;
                        provider.Phone          = temp.Phone;
                        provider.Contact        = temp.Contact;
                        provider.ContactMail    = temp.ContactMail;
                        provider.ContactPhone   = temp.ContactPhone;
                        provider.EnterpriseMail = temp.EnterpriseMail;
                        provider.NIT            = temp.NIT;
                        provider.Type           = temp.Type;
                        Providers.Add(provider);
                    }

                    return(Providers);
                }
                else
                {
                    return(Providers);
                }
            }
        }
Ejemplo n.º 6
0
 public Provider ExtractById(long?code)
 {
     using (var context = new ProyectoMaestriaEntities())
     {
         // Query for all blogs with names starting with B
         //var ComedorExtracted = from b in context.Comedor
         //            where b.ID.Equals(id)
         //            select b;
         var proveedor = context.Provider.SingleOrDefault(x => x.ID == code);
         if (proveedor != null)
         {
             return(new Provider
             {
                 //   public long ID { get; set; }
                 ID = proveedor.ID,
                 Code = proveedor.Code,
                 Name = proveedor.Name,
                 Address = proveedor.Address,
                 Neiborhood = proveedor.Neiborhood,
                 City = proveedor.City,
                 Phone = proveedor.Phone,
                 Contact = proveedor.Contact,
                 ContactPhone = proveedor.ContactPhone,
                 ContactMail = proveedor.ContactMail,
                 EnterpriseMail = proveedor.EnterpriseMail,
                 NIT = proveedor.NIT,
                 Type = proveedor.Type
             });
         }
         else
         {
             return(null);
         }
         //// Query for the Blog named ADO.NET Blog
         //var blog = context.Blogs
         //                .Where(b => b.Name == "ADO.NET Blog")
         //                .FirstOrDefault();
     }
 }
Ejemplo n.º 7
0
        public List <Transport> ExtractAll()
        {
            List <Transport> transports = new List <Transport>();

            using (var context = new ProyectoMaestriaEntities())
            {
                var result = context.Transport.ToList();


                if (result != null)
                {
                    foreach (var temp in result)
                    {
                        Transport transport = new Transport();
                        transport.ID                  = temp.ID;
                        transport.Code                = temp.Code;
                        transport.CarPlate            = temp.CarPlate;
                        transport.Brand               = temp.Brand;
                        transport.Year                = temp.Year;
                        transport.PersonInCharge      = temp.PersonInCharge;
                        transport.PhonePersonInCharge = temp.PhonePersonInCharge;
                        transport.MailPersonInCharge  = temp.MailPersonInCharge;
                        transport.PaymentUnity        = temp.PaymentUnity;
                        transport.PaymentMeasurement  = temp.PaymentMeasurement;
                        transport.PaymentValue        = temp.PaymentValue;
                        transport.Availability        = temp.Availability;
                        transport.TransportType       = temp.TransportType;
                        transport.IDProvider          = temp.IDProvider;
                        transports.Add(transport);
                    }

                    return(transports);
                }
                else
                {
                    return(transports);
                }
            }
        }
Ejemplo n.º 8
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.º 9
0
 public DiningRoom GetComedorByID(long id)
 {
     using (var context = new ProyectoMaestriaEntities())
     {
         // Query for all blogs with names starting with B
         //var ComedorExtracted = from b in context.Comedor
         //            where b.ID.Equals(id)
         //            select b;
         var comedor = context.DiningRoom.SingleOrDefault(x => x.ID == id);
         if (comedor != null)
         {
             return(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
             });
         }
         else
         {
             return(null);
         }
         //// Query for the Blog named ADO.NET Blog
         //var blog = context.Blogs
         //                .Where(b => b.Name == "ADO.NET Blog")
         //                .FirstOrDefault();
     }
 }
Ejemplo n.º 10
0
        public List <DiningRoom> GettAllDinners()
        {
            List <DiningRoom> diningRooms = new List <DiningRoom>();

            using (var context = new ProyectoMaestriaEntities())
            {
                var result = context.DiningRoom.ToList();


                if (result != null)
                {
                    foreach (var temp in result)
                    {
                        DiningRoom diningRoom = new DiningRoom();
                        diningRoom.ID                = temp.ID;
                        diningRoom.Code              = temp.Code;
                        diningRoom.Name              = temp.Name;
                        diningRoom.Address           = temp.Address;
                        diningRoom.Phone             = temp.Phone;
                        diningRoom.Email             = temp.Email;
                        diningRoom.Neiborhood        = temp.Neiborhood;
                        diningRoom.City              = temp.City;
                        diningRoom.Contact           = temp.Contact;
                        diningRoom.ContactEmail      = temp.ContactEmail;
                        diningRoom.ContactPhone      = temp.ContactPhone;
                        diningRoom.ChildNumber       = temp.ChildNumber;
                        diningRoom.ScheduleReception = temp.ScheduleReception;
                        diningRooms.Add(diningRoom);
                    }

                    return(diningRooms);
                }
                else
                {
                    return(diningRooms);
                }
            }
        }
Ejemplo n.º 11
0
        public List <SystemUser> GetAll()
        {
            List <SystemUser> transports = new List <SystemUser>();

            using (var context = new ProyectoMaestriaEntities())
            {
                var result = context.SystemUser.ToList();


                if (result != null)
                {
                    foreach (var temp in result)
                    {
                        //result.Password = systemuser.Password;
                        //result.Name = systemuser.Name;
                        //result.LastName = systemuser.LastName;
                        //result.UserType = systemuser.UserType;
                        //result.ProviderID = systemuser.ProviderID;
                        SystemUser systemuser = new SystemUser();
                        systemuser.ID       = temp.ID;
                        systemuser.Username = temp.Username;

                        systemuser.Name       = temp.Name;
                        systemuser.LastName   = temp.LastName;
                        systemuser.UserType   = temp.UserType;
                        systemuser.ProviderID = temp.ProviderID;

                        transports.Add(systemuser);
                    }

                    return(transports);
                }
                else
                {
                    return(transports);
                }
            }
        }
Ejemplo n.º 12
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.º 13
0
        public string InsertarPreorder(PreOrder preorder)
        {
            int result;

            try
            {
                using (var context = new ProyectoMaestriaEntities())
                {
                    if (preorder.PreOrderDate == null)
                    {
                        preorder.PreOrderDate = DateTime.Now;
                    }

                    var std = new PreOrder()
                    {
                        IDDiningRoom = preorder.IDDiningRoom,
                        IDRecipe     = preorder.IDRecipe,
                        PreOrderDate = preorder.PreOrderDate,
                        Accepted     = preorder.Accepted
                    };
                    context.PreOrder.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.º 14
0
 public Product Get(string code)
 {
     using (var context = new ProyectoMaestriaEntities())
     {
         var product = context.Product.SingleOrDefault(x => x.Code == code);
         if (product != null)
         {
             return(new Product
             {
                 ID = product.ID,
                 Code = product.Code,
                 Name = product.Name,
                 Description = product.Description,
                 Preservation = product.Preservation,
                 ProductType = product.ProductType
             });
         }
         else
         {
             return(null);
         }
     }
 }
Ejemplo n.º 15
0
        public string UpdatePreorder(PreOrder preorder)
        {
            int modify = 0;

            try
            {
                using (var context = new ProyectoMaestriaEntities())
                {
                    var result = context.PreOrder.SingleOrDefault(b => b.ID == preorder.ID);
                    if (result != null)
                    {
                        result.IDDiningRoom = preorder.IDDiningRoom;
                        result.IDRecipe     = preorder.IDRecipe;
                        result.PreOrderDate = preorder.PreOrderDate;
                        result.Accepted     = preorder.Accepted;
                        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.º 16
0
        public List <Ingredient> GettAll()
        {
            List <Ingredient> ingredients = new List <Ingredient>();

            using (var context = new ProyectoMaestriaEntities())
            {
                var result = context.Ingredient.ToList();


                if (result != null)
                {
                    foreach (var temp in result)
                    {
                        //result.Password = systemuser.Password;
                        //result.Name = systemuser.Name;
                        //result.LastName = systemuser.LastName;
                        //result.UserType = systemuser.UserType;
                        //result.ProviderID = systemuser.ProviderID;
                        Ingredient ingredient = new Ingredient();
                        ingredient.Id        = temp.Id;
                        ingredient.IDProduct = temp.IDProduct;

                        ingredient.IDRecipe = temp.IDRecipe;
                        ingredient.Quantity = temp.Quantity;


                        ingredients.Add(ingredient);
                    }

                    return(ingredients);
                }
                else
                {
                    return(ingredients);
                }
            }
        }
Ejemplo n.º 17
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);
                }
            }
        }
Ejemplo n.º 18
0
        public List <PreOrderItem> GetByOrder(long Preorder)
        {
            List <PreOrderItem> ingredients = new List <PreOrderItem>();

            using (var context = new ProyectoMaestriaEntities())
            {
                // Query for all blogs with names starting with B
                //var ComedorExtracted = from b in context.Comedor
                //            where b.ID.Equals(id)
                //            select b;
                var repetido = context.PreOrderItem.Where(x => x.IDPreOrder == Preorder);
                foreach (PreOrderItem ing in repetido)
                {
                    PreOrderItem ingr = new PreOrderItem();
                    ingr.ID         = ing.ID;
                    ingr.IDPreOrder = ing.IDPreOrder;
                    ingr.IDProduct  = ing.IDProduct;
                    ingr.Quantity   = ing.Quantity;

                    ingredients.Add(ingr);
                }
                return(ingredients);
            }
        }