示例#1
0
 public IActionResult Create(Customer customer)
 {
     if (ModelState.IsValid)
     {
         _db.Customers.Add(customer);
         _db.SaveChanges();
         TempData["modifiedId"]   = customer.Id;
         TempData["modification"] = "create";
         TempData["customerName"] = customer.Firstname + " " + customer.Lastname;
         return(RedirectToAction("Index"));
     }
     return(View(customer));
 }
示例#2
0
 public IActionResult Create(AppointmentDropDownVM appointmentVM)
 {
     if (ModelState.IsValid)
     {
         _db.Appointments.Add(appointmentVM.Appointment);
         _db.SaveChanges();
         TempData["modifiedId"]   = appointmentVM.Appointment.Id;
         TempData["modification"] = "create";
         Customer customer = _db.Customers.FirstOrDefault(c => c.Id == appointmentVM.Appointment.IdCustomer);
         TempData["customerName"] = customer.Firstname + " " + customer.Lastname;
         TempData["dateTime"]     = appointmentVM.Appointment.DateHour;
         return(RedirectToAction("Index"));
     }
     return(View(appointmentVM.Appointment));
 }