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)); }
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)); }
public static void SaveChanges() { using (GetCoffeeDBEntities db = new GetCoffeeDBEntities()) { db.SaveChanges(); } }
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(); } }
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)); }
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)); }
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)); }
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)); }
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)); }
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(); } }
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); }
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); }
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); }