Exemplo n.º 1
0
        //Get Edit
        public async Task <IActionResult> Edit(int id)
        {
            if (id == null)
            {
                NotFound();
            }
            var lstProducts = (IEnumerable <Products>)(from p in _db.products
                                                       join a in _db.appointmentsProducts
                                                       on p.Id equals a.ProductId
                                                       where a.appointmentId == id
                                                       select p).Include("ProductTypes");
            AppointmentsDetailsVM advm = new AppointmentsDetailsVM()
            {
                appointments = _db.appointments.Include(a => a.SalesPerson).Where(a => a.Id == id).FirstOrDefault(),
                lstUsers     = _db.users.Where(u => u.LockoutEnd == null || u.LockoutEnd < DateTime.Now).ToList(),
                lstproducts  = lstProducts.ToList()
            };

            return(View(advm));
        }
Exemplo n.º 2
0
 public async Task <IActionResult> Edit(int id, AppointmentsDetailsVM value)
 {
     if (ModelState.IsValid)
     {
         value.appointments.AppointmentDate = value.appointments.AppointmentDate.AddHours(value.appointments.AppointmentTime.Hour).AddMinutes(value.appointments.AppointmentTime.Minute);
         var dbappointment = _db.appointments.Where(a => a.Id == value.appointments.Id).FirstOrDefault();
         dbappointment.CustomerName    = value.appointments.CustomerName;
         dbappointment.CustomerEmail   = value.appointments.CustomerEmail;
         dbappointment.CustomerPhone   = value.appointments.CustomerPhone;
         dbappointment.AppointmentDate = value.appointments.AppointmentDate;
         dbappointment.Confirmed       = value.appointments.Confirmed;
         if (User.IsInRole(SD.SuperAdminUser))
         {
             dbappointment.SalesPersonID = value.appointments.SalesPersonID;
         }
         _db.SaveChanges();
         return(RedirectToAction(nameof(Index)));
     }
     return(View(value));
 }