public static void Initialize(FlyContext db) { if (!db.clients.Any()) { db.clients.AddRange(ListClients); } if (!db.destinations.Any()) { db.destinations.AddRange(destinations); } if (!db.sources.Any()) { db.sources.AddRange(sources); } if (!db.flyghts.Any()) { db.flyghts.AddRange(flyghts); } if (!db.orders.Any()) { db.orders.AddRange(orders); } db.SaveChanges(); }
public IActionResult OrderBuy(int id) { Order order = new Order(); order.FlyghtId = id; Client user = new Client(); user = db.clients.FirstOrDefault(u => u.Login == User.Identity.Name); order.ClientId = user.Id; person = user.Id; db.orders.Add(order); db.SaveChanges(); return(View()); }
public IActionResult Register(Client client) { if (!nullErr(client)) { if (!lenghtErr(client)) { { Client person = new Client(); person = db.clients.FirstOrDefault(u => u.Login == client.Login && u.Password == client.Password); if (person == null) { { db.Add(client); db.SaveChanges(); return(RedirectToAction("Index", "Sign")); } } ViewBag.ErrSame = "Introdu alta combinatie login-parola"; } } } return(View()); }