public void CancelOrder(long orderId) { var order = _context.Order.Find(orderId); order.OrderStatus = "CANCELED"; _context.Entry <Order>(order).State = EntityState.Modified; _context.SaveChanges(); }
public void UpdateAddress(Address address) { Address addressFromDb = _context.Address.Find(address.Id); addressFromDb.DeliveryAddress = address.DeliveryAddress; addressFromDb.ReceiverName = address.ReceiverName; addressFromDb.ReceiverPhone = address.ReceiverPhone; _context.Entry <Address>(addressFromDb).State = EntityState.Modified; _context.SaveChanges(); }
public void UpdateProductInfo(long productId, string productName, string productUrl, bool isOnSale, decimal price) { using (AirShoppContext _context = new AirShoppContext()) { try { var product = _context.Product.Where(p => p.Id == productId).FirstOrDefault(); if (product != null) { product.ProductName = productName; if (productUrl != null) { product.Url = productUrl; } product.IsOnSale = isOnSale; product.Price = price; _context.Entry(product).State = System.Data.Entity.EntityState.Modified; _context.SaveChanges(); } } catch (Exception) { throw; } } }
public void DeleteCourier(long courierId) { Courier courier = _context.Courier.Where(x => x.Id == courierId).ToList().FirstOrDefault(); _context.Entry <Courier>(courier).State = EntityState.Deleted; _context.SaveChanges(); }
public void UpdateCartItem(long cartItemId) { using (AirShoppContext _context = new AirShoppContext()) { CartItem cartItem = _context.CartItem.Find(cartItemId); cartItem.ItemStatus = Constants.BOUGHT; _context.Entry <CartItem>(cartItem).State = EntityState.Modified; _context.SaveChanges(); } }
public void UpdateProductDiscount(long productId, decimal discounts) { using (AirShoppContext _context = new AirShoppContext()) { var d = _context.Discount.Where(dt => dt.ProductId == productId).FirstOrDefault(); if (d != null) { d.Discounts = discounts; _context.Entry(d).State = System.Data.Entity.EntityState.Modified; _context.SaveChanges(); } } }
public void UpdateCustomer(Customer customer) { _context.Entry <Customer>(customer).State = EntityState.Modified; _context.SaveChanges(); }