public IActionResult Connexion(Deliveryman deliveryman) { int idDeliveryman = DeliverymanManager.GetIdDeliveryman(deliveryman.Login); string password = DeliverymanManager.GetPassword(idDeliveryman, deliveryman.Login); //Si ca correspond, passe à la vue HomeDeliveryman if (deliveryman.Password == password) { HttpContext.Session.SetInt32("IdDeliveryman", idDeliveryman); return(RedirectToAction("HomeDeliveryman", "Deliveryman", new { id = idDeliveryman })); } //Si ca ne correspond pas, reste sur la connexion else { return(View()); } }
static void Main(string[] args) { var customerDbManager = new CustomerManager(Configuration); var deliverymanDbManager = new DeliverymanManager(Configuration); var deliveryDbManager = new DeliveryManager(Configuration); var orderDbManager = new OrderManager(Configuration); var cityDbManager = new CityManager(Configuration); Console.WriteLine("Customer [C], Deliveryman [D]"); string customerDeliverymanChoice = Console.ReadLine(); if (customerDeliverymanChoice == "C") { Console.WriteLine("Already registered [1], New registration [2]"); string registrationChoice = Console.ReadLine(); if (registrationChoice == "1") { Console.WriteLine("Username"); string usernameC = Console.ReadLine(); Console.WriteLine("Password"); string passwordC = Console.ReadLine(); int idCustomerTryingToConnect = customerDbManager.GetIdCustomer(usernameC); //En fonction de l'id du customer while (passwordC != customerDbManager.GetPassword(idCustomerTryingToConnect, usernameC)) { Console.WriteLine(passwordC); Console.WriteLine("Connection denied. Try again"); Console.WriteLine("Username"); usernameC = Console.ReadLine(); Console.WriteLine("Password"); passwordC = Console.ReadLine(); idCustomerTryingToConnect = customerDbManager.GetIdCustomer(usernameC); } Console.WriteLine("Connection successful"); Program.Suite(idCustomerTryingToConnect); } else { Console.WriteLine("New registration !"); Console.WriteLine("Name : "); string nameNewCustomer = Console.ReadLine(); Console.WriteLine("Lastname : "); string lastNameNewCustomer = Console.ReadLine(); Console.WriteLine("City : "); string cityNewCustomer = Console.ReadLine(); Console.WriteLine("ZIP : "); string zipNewCustomer = Console.ReadLine(); int idCity = cityDbManager.GetIdCity(cityNewCustomer.ToLower(), zipNewCustomer); if (idCity == 0) { cityDbManager.AddCity(new City { Name = cityNewCustomer, Zip_code = int.Parse(zipNewCustomer) }); idCity = cityDbManager.GetIdCity(cityNewCustomer.ToLower(), zipNewCustomer); } Console.WriteLine("Address : "); string addressNewCustomer = Console.ReadLine(); Console.WriteLine("Login : "******"Password : "******"Congratulations, your account has been created ! You can now start ordering food !"); int idNewCustomer = customerDbManager.GetIdCustomer(LoginNewCustomer); Program.Suite(idNewCustomer); } } else { Console.WriteLine("Welcome to the delivery management"); Console.WriteLine("Username"); string usernameDM = Console.ReadLine(); Console.WriteLine("Password"); string passwordDM = Console.ReadLine(); int idDeliverymanTryingToConnect = deliverymanDbManager.GetIdDeliveryman(usernameDM); //En fonction de l'id du customer while (passwordDM != deliverymanDbManager.GetPassword(idDeliverymanTryingToConnect, usernameDM)) { Console.WriteLine("Connection denied. Try again"); Console.WriteLine("Username"); usernameDM = Console.ReadLine(); Console.WriteLine("Password"); passwordDM = Console.ReadLine(); } Console.WriteLine("Connection successful"); Console.WriteLine("Which delivery have you done ? Insert the ID"); var deliverys = deliveryDbManager.GetAllDelivery(idDeliverymanTryingToConnect); //En fonction de l'id du deliveryman foreach (var delivery in deliverys) { Console.WriteLine(delivery.ToString()); } string deliveryDone = Console.ReadLine(); Console.WriteLine("Thank you ! The delivery " + deliveryDbManager.GetDelivery(int.Parse(deliveryDone)) + " has been successfully executed"); //deliveryDbManager.changeStatusDeliveryToDone(idDelivery); } }