Exemplo n.º 1
0
        //add shoe to the database
        public static int AddShoe(addShoe sh)
        {
            using (DB_shoesEntities5 db = new DB_shoesEntities5())
            {
                try
                {
                    Sho s = converters.ShoeConverter.ShoeToDAL(sh.shoe);

                    int x;
                    for (int i = 0; i < sh.colors.Length; i++)
                    {
                        x = sh.colors[i];
                        Color c = db.Colors.Where(c1 => c1.id_color == x).First();
                        s.Colors.Add(c);
                    }
                    db.Shoes.Add(s);
                    db.SaveChanges();

                    int id = db.Shoes.Select(s1 => s1.id_shoe).Max();

                    return(id);
                }
                catch (Exception e)
                { return(0); }
            }
        }
Exemplo n.º 2
0
 public int onUpload([FromBody] addShoe shoe)
 {
     return(BL.ShoesBL.AddShoe(shoe));
 }