public void CreateOrder(OrderPost order) { order.OrderPlaced = DateTime.Now; _db.OrdersPost.Add(order); _db.SaveChanges(); order.OrderTotal = _cart.GetCartTotal(); var cartItems = _cart.CartItems; foreach (var item in cartItems) { var orderDetail = new OrderDetailPost() { Amount = item.Amount, ProductId = item.Product.Id, OrderPostId = order.OrderPostId, Price = item.Product.Price }; _db.OrderDetailsPost.Add(orderDetail); } _db.SaveChanges(); }
public OrderPickUp SavePickUpOrder(int id, Status status) { var dbEntity = context.OrdersPickUp.Find(id); dbEntity.Status = status; var text = $"Your order has changed status. Actual status is {status}. For more information follow the link: https://mayakelectronics20191126070610.azurewebsites.net/Account/YourAccount"; EmailSender.SendEmail(dbEntity.Email, text); context.SaveChanges(); return(dbEntity); }