Example #1
0
        public static Order insertOrder(Order o)
        {
            dataContext = new RobaSegonaMaEntities();
            try
            {
                dataContext.Orders.Add(o);
                dataContext.SaveChanges();

                Cloth c = dataContext.Clothes.Where(x => x.Id == o.Clothes_Id && x.active == true).FirstOrDefault();
                c.active = false;

                Requestor r = dataContext.Requestors.FirstOrDefault(x => x.Id == o.Requestor_Id);

                r.points += c.Classification.value;

                dataContext.SaveChanges();

                return(o);
            }
            catch (Exception e)
            {
                return(null);
            }
            dataContext = new RobaSegonaMaEntities();
        }
Example #2
0
        public static List <Warehouse> getWarehousesByCloth(Cloth c)
        {
            List <Warehouse> lw    = new List <Warehouse>();
            bool             first = true;
            List <Cloth>     lc    = null;

            lc = dc.Clothes.Where(x => x.Size_Id == c.Size_Id && x.Color_Id == c.Color_Id && x.Classification_Id == c.Classification_Id && c.Gender_Id == x.Gender_Id && x.active == true).ToList();

            foreach (Cloth cloth in lc)
            {
                if (first)
                {
                    Warehouse w = dc.Warehouses.Where(x => x.Id == cloth.Warehouse_Id).FirstOrDefault();
                    lw.Add(w);
                    first = false;
                }
                else if (!lw.Contains(cloth.Warehouse))
                {
                    Warehouse w = dc.Warehouses.Where(x => x.Id == cloth.Warehouse_Id).FirstOrDefault();
                    lw.Add(w);
                }
            }

            if (lw != null)
            {
                lw = lw.OrderBy(x => x.city).ToList();
            }



            return(lw);
        }
        public static Cloth getCloth(int id)
        {
            RobaSegonaMaEntities dc = new RobaSegonaMaEntities();

            Cloth c = dc.Clothes.Where(x => x.Id == id).FirstOrDefault();

            return(c);
        }
        public static Cloth updateCloth(int id, Cloth c)
        {
            try
            {
                Cloth c2 = dc.Clothes.Where(x => x.Id == id).SingleOrDefault();


                if (c.active != null)
                {
                    c2.active = c.active;
                }

                if (c.Color != null)
                {
                    c2.Color = c.Color;
                }
                if (c.Gender != null)
                {
                    c2.Gender = c.Gender;
                }
                if (c.Size != null)
                {
                    c2.Size = c.Size;
                }
                if (c.Classification != null)
                {
                    c2.Classification = c.Classification;
                }
                if (c.Warehouse != null)
                {
                    c2.Warehouse = c.Warehouse;
                }
                if (c.dateCreated != null)
                {
                    c2.dateCreated = c.dateCreated;
                }

                dc.SaveChanges();

                return(c2);
            }
            catch (Exception ex)
            {
                return(null);
            }
            dc = new RobaSegonaMaEntities();
        }
        public static Cloth insertCloth(Cloth c)
        {
            try
            {
                dc.Clothes.Add(c);

                dc.SaveChanges();

                dc = new RobaSegonaMaEntities();

                return(c);
            }
            catch (Exception e)
            {
                return(null);
            }
        }