public ActionResult AddCustomer([Bind(Include = "Firstname, Lastname, Mail, PhoneNumber, Budget")] Customer customer) { if (ModelState.IsValid) { db.Customers.Add(customer); db.SaveChanges(); return(RedirectToAction("ListCustomers")); } return(View()); }
public ActionResult AddBroker([Bind(Include = "Firstname, Lastname, Mail, PhoneNumber")] Broker broker) { if (ModelState.IsValid) { db.Brokers.Add(broker); db.SaveChanges(); return(RedirectToAction("ListBrokers")); } return(View()); }
public ActionResult AddAppointment([Bind(Include = "AppointmentID, DateHour, BrokerID, CustomerID, Subject")] Appointment appointment) { var queryResult = db.Appointments.SingleOrDefault(a => (a.BrokerID == appointment.BrokerID && a.DateHour == appointment.DateHour) || (a.CustomerID == appointment.CustomerID && a.DateHour == appointment.DateHour)); if (queryResult != null) { ModelState.AddModelError("DateHour", "le rendez vous est déjà pris"); } if (ModelState.IsValid) { db.Appointments.Add(appointment); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.BrokerID = new SelectList(db.Brokers, "BrokerID", "FullName"); ViewBag.CustomerID = new SelectList(db.Customers, "CustomerID", "FullName"); return(View()); }