public string Buy(Order order) { _db.Orders.Add(order); // сохраняем в бд все изменения _db.SaveChanges(); return("Спасибо, " + order.User + ", за покупку!"); }
public static void Initialize(MobileContext context) { if (!context.Phones.Any()) { context.Phones.AddRange( new Phone { Name = "iPhone X", Company = "Apple", Price = 600 }, new Phone { Name = "Samsung Galaxy Edge", Company = "Samsung", Price = 550 }, new Phone { Name = "Pixel 3", Company = "Google", Price = 500 } ); context.SaveChanges(); } }