Exemple #1
0
        public IHttpActionResult PutUser(int id, User user)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != user.id)
            {
                return(BadRequest());
            }

            db.Entry(user).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!UserExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Exemple #2
0
        public IHttpActionResult PutOrderProduct(long id, OrderProduct orderProduct)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != orderProduct.code)
            {
                return(BadRequest());
            }

            db.Entry(orderProduct).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!OrderProductExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Exemple #3
0
 public static void SaveChanges()
 {
     using (GetCoffeeDBEntities db = new GetCoffeeDBEntities())
     {
         db.SaveChanges();
     }
 }
Exemple #4
0
 public static void Add(Category category)
 {
     using (GetCoffeeDBEntities db = new GetCoffeeDBEntities())
     {
         db.Categories.Add(category);
         db.SaveChanges();
     }
 }
 public static void updateOrder(OrderDTO order)
 {
     using (GetCoffeeDBEntities db = new GetCoffeeDBEntities())
     {
         Order o = OrderConverter.DTOToDAL(order);
         db.Entry(o).State = EntityState.Modified;
         db.SaveChanges();
     }
 }
Exemple #6
0
        public static ShopDTO Add(ShopDTO shop)
        {
            Shop s = ShopConverter.DTOToDAL(shop);

            using (GetCoffeeDBEntities db = new GetCoffeeDBEntities())
            {
                db.Shops.Add(s);
                db.SaveChanges();
            }
            return(ShopConverter.DALToDTO(s));
        }
Exemple #7
0
        public static ShopDTO Entry(ShopDTO shop)
        {
            Shop shopDal = ShopConverter.DTOToDAL(shop);

            using (GetCoffeeDBEntities db = new GetCoffeeDBEntities())
            {
                db.Entry(shopDal).State = EntityState.Modified;
                db.SaveChanges();
            }
            return(ShopConverter.DALToDTO(shopDal));
        }
        public static OrderDTO Add(OrderDTO order)
        {
            Order o = OrderConverter.DTOToDAL(order);

            using (GetCoffeeDBEntities db = new GetCoffeeDBEntities())
            {
                db.Orders.Add(o);
                db.SaveChanges();
            }
            return(OrderConverter.DALToDTO(o));
        }
Exemple #9
0
        public static OrderProductDTO Add(OrderProductDTO orderProducts)
        {
            OrderProduct op = OrderProductConverter.DTOToDAL(orderProducts);

            using (GetCoffeeDBEntities db = new GetCoffeeDBEntities())
            {
                db.OrderProducts.Add(op);
                db.SaveChanges();
            }
            return(OrderProductConverter.DALToDTO(op));
        }
Exemple #10
0
        public static ProductDTO Add(ProductDTO product)
        {
            Product p = ProductConverter.DTOToDAL(product);

            using (GetCoffeeDBEntities db = new GetCoffeeDBEntities())
            {
                db.Products.Add(p);
                db.SaveChanges();
            }
            return(ProductConverter.DALToDTO(p));
        }
        public static UsersDTO Add(UsersDTO userD)
        {
            User user = UsersConverter.DTOToDAL(userD);

            using (GetCoffeeDBEntities db = new GetCoffeeDBEntities())
            {
                db.Users.Add(user);
                db.SaveChanges();
            }
            return(UsersConverter.DALToDTO(user));
        }
Exemple #12
0
        public static ShopProductsDTO Add(ShopProductsDTO shopProducts)
        {
            Shop_sProduct ss = ShopProductsConverter.DTOToDAL(shopProducts);

            using (GetCoffeeDBEntities db = new GetCoffeeDBEntities())
            {
                db.Shop_sProduct.Add(ss);
                db.SaveChanges();
            }
            return(ShopProductsConverter.DALToDTO(ss));
        }
Exemple #13
0
 public static void updateShopProducts(List <ShopProductsDTO> shop_sProducts)
 {
     using (GetCoffeeDBEntities db = new GetCoffeeDBEntities())
     {
         List <Shop_sProduct> products = ShopProductsConverter.DTOsToDALs(shop_sProducts);
         products.ForEach(item =>
         {
             db.Entry(item).State = EntityState.Modified;
         });
         db.SaveChanges();
     }
 }
Exemple #14
0
 public static bool DeleteProduct(long id)
 {
     using (GetCoffeeDBEntities db = new GetCoffeeDBEntities())
     {
         Product product = db.Products.Find(id);
         if (product == null)
         {
             return(false);
         }
         db.Products.Remove(product);
         db.SaveChanges();
     }
     return(true);
 }
Exemple #15
0
 public static bool DeleteShop(long id)
 {
     using (GetCoffeeDBEntities db = new GetCoffeeDBEntities())
     {
         Shop shop = db.Shops.Find(id);
         if (shop == null)
         {
             return(false);
         }
         db.Shops.Remove(shop);
         db.SaveChanges();
     }
     return(true);
 }
Exemple #16
0
 public static bool DeleteOrder(long id)
 {
     using (GetCoffeeDBEntities db = new GetCoffeeDBEntities())
     {
         Order order = db.Orders.Find(id);
         if (order == null)
         {
             return(false);
         }
         db.Orders.Remove(order);
         db.SaveChanges();
     }
     return(true);
 }