示例#1
0
        public async Task <IActionResult> Edit(int id, AppointmentDetailsViewModel objAppointmentVM, string strUrl)
        {
            if (ModelState.IsValid)
            {
                var appointmentFromDb = _db.Appointments.Where(a => a.Id == objAppointmentVM.Appointment.Id).FirstOrDefault();

                appointmentFromDb.CustomerName    = objAppointmentVM.Appointment.CustomerName;
                appointmentFromDb.CustomerEmail   = objAppointmentVM.Appointment.CustomerEmail;
                appointmentFromDb.CustomerAddress = objAppointmentVM.Appointment.CustomerAddress;
                appointmentFromDb.AppointmentDate = objAppointmentVM.Appointment.AppointmentDate;
                appointmentFromDb.isConfirmed     = objAppointmentVM.Appointment.isConfirmed;
                appointmentFromDb.isCompleted     = objAppointmentVM.Appointment.isCompleted;
                if (User.IsInRole(SD.SuperAdminEndUser))
                {
                    appointmentFromDb.SalesPersonId = objAppointmentVM.Appointment.SalesPersonId;
                }
                else
                {
                    appointmentFromDb.SalesPersonId = null;
                }
                _db.SaveChanges();

                return(Redirect(strUrl));
            }

            return(View(objAppointmentVM));
        }
示例#2
0
        public async Task <IActionResult> Edit(int id, AppointmentDetailsViewModel objAppointmentVM)
        {
            if (ModelState.IsValid)
            {
                objAppointmentVM.Appointments.AppointmentDate = objAppointmentVM.Appointments.AppointmentDate
                                                                .AddHours(objAppointmentVM.Appointments.AppointmentTime.Hour)
                                                                .AddMinutes(objAppointmentVM.Appointments.AppointmentTime.Minute); // this adds the time to the date to save it in the db

                var appointmentFromDb = await _db.Appointments.Where(a => a.Id == objAppointmentVM.Appointments.Id).FirstOrDefaultAsync();

                appointmentFromDb.CustomerName        = objAppointmentVM.Appointments.CustomerName;
                appointmentFromDb.CustomerPhoneNumber = objAppointmentVM.Appointments.CustomerPhoneNumber;
                appointmentFromDb.CustomerEmail       = objAppointmentVM.Appointments.CustomerEmail;
                appointmentFromDb.AppointmentDate     = objAppointmentVM.Appointments.AppointmentDate;
                appointmentFromDb.IsConfirmed         = objAppointmentVM.Appointments.IsConfirmed;
                if (User.IsInRole(SD.SuperAdminEndUser))
                {
                    appointmentFromDb.SalesPersonId = objAppointmentVM.Appointments.SalesPersonId;
                }

                await _db.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }

            return(View(objAppointmentVM));
        }
        public async Task <IActionResult> Delete(int?id)
        {
            //check if id is null
            if (id == null)
            {
                return(NotFound());
            }

            // we need to retrieve all of the products for an appointment, so we need to combine from ProductsSelectedForAppointment and Products models
            // and filter that based on appointment ID that is passed in and retrieve those products
            // we will use Linq to do that
            // join on tables, converted selected products to IEnumerable of products
            var productList = (IEnumerable <Products>)(from p in _db.Products
                                                       join a in _db.ProductsSelectedForAppointments on p.Id equals a.ProductId
                                                       where a.AppointmentId == id
                                                       select p).Include("ProductTypes");


            // We need new AppointmentsViewModel and to populate with specific appointment data
            AppointmentDetailsViewModel objAppointmentVM = new AppointmentDetailsViewModel()
            {
                Appointment = _db.Appointments.Include(a => a.SalesPerson).Where(a => a.Id == id).FirstOrDefault(),
                SalesPerson = _db.ApplicationUser.ToList(),
                Products    = productList.ToList()
            };


            // now that we have our products we ween to pas the m on to the view don't we? ;-)

            return(View(objAppointmentVM));
        }
        public async Task <IActionResult> Edit(int id, AppointmentDetailsViewModel appVM)
        {
            if (ModelState.IsValid)
            {
                appVM.Appointment.AppointmentDate = appVM.Appointment.AppointmentDate
                                                    .AddHours(appVM.Appointment.AppointmentTime.Hour)
                                                    .AddMinutes(appVM.Appointment.AppointmentTime.Minute);

                var appointmentFromDb = this.db.Appointments.Where(a => a.Id == appVM.Appointment.Id).FirstOrDefault();

                appointmentFromDb.CustomerName        = appVM.Appointment.CustomerName;
                appointmentFromDb.CustomerEmail       = appVM.Appointment.CustomerEmail;
                appointmentFromDb.CustomerPhoneNumber = appVM.Appointment.CustomerPhoneNumber;
                appointmentFromDb.AppointmentDate     = appVM.Appointment.AppointmentDate;
                appointmentFromDb.IsConfirmed         = appVM.Appointment.IsConfirmed;

                if (User.IsInRole(StaticDetails.SuperAdminEndUser))
                {
                    appointmentFromDb.SalesPersonId = appVM.Appointment.SalesPersonId;
                }
                await this.db.SaveChangesAsync();

                return(this.RedirectToAction(nameof(Index)));
            }

            return(this.View(appVM));
        }
示例#5
0
        public IActionResult Details(int id)
        {
            var appointment = _appointmentService.GetById(id);

            if (appointment == null)
            {
                return(NotFound());
            }

            var model = new AppointmentDetailsViewModel()
            {
                Id                = appointment.Id,
                TechnicianId      = appointment.TechnicianId,
                TechnicianName    = appointment.TechnicianName,
                Observations      = appointment.Observations,
                StartDate         = appointment.StartDate,
                ExpectedFinalDate = appointment.ExpectedFinalDate,
                RealFinalDate     = appointment.RealFinalDate,
                Address           = appointment.Address,
                AppointmentName   = appointment.AppointmentName,
                City              = appointment.City,
                District          = appointment.District,
                Number            = appointment.Number,
                Postcode          = appointment.Postcode,
                State             = appointment.State,
                Completed         = appointment.Completed
            };

            return(View(model));
        }
示例#6
0
        //GET Edit
        public async Task <IActionResult> Edit(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var productList = (IEnumerable <Product>)(from p in _db.Products
                                                      join a in _db.ProductAddToAppointment
                                                      on p.ProductId equals a.ProductId
                                                      where a.AppointmentId == id
                                                      select p);
            List <CartItem> cart = new List <CartItem>();

            foreach (Product item in productList)
            {
                CartItem halo = new CartItem();
                var      prd  = _db.ProductAddToAppointment.Where(m => m.AppointmentId == id && m.ProductId == item.ProductId).FirstOrDefault();
                halo.itemCart  = item;
                halo.quantity  = prd.Count;
                halo.totalItem = prd.Total;

                cart.Add(halo);
            }

            AppointmentDetailsViewModel objAppointmentVM = new AppointmentDetailsViewModel()
            {
                Appointment = _db.Appoinments.Include(a => a.SalePerson).Where(a => a.Id == id).FirstOrDefault(),
                SalesPerson = _db.ApplicationAdminUser.ToList(),
                Products    = cart,
            };

            return(View(objAppointmentVM));
        }
        public async Task <IActionResult> Edit(int id, AppointmentDetailsViewModel appDetailsVM)
        {
            if (ModelState.IsValid)
            {
                //combine the apt date and time from view inside the apt date
                appDetailsVM.Appointment.AppointmentDate = appDetailsVM.Appointment.AppointmentDate
                                                           .AddHours(appDetailsVM.Appointment.AppointmentTime.Hour)
                                                           .AddMinutes(appDetailsVM.Appointment.AppointmentTime.Minute);

                //grab apt obj from db
                var appointmentFromDb = _db.Appointments.Where(a => a.Id == appDetailsVM.Appointment.Id).FirstOrDefault();
                appointmentFromDb.CustomerName        = appDetailsVM.Appointment.CustomerName;
                appointmentFromDb.CustomerEmail       = appDetailsVM.Appointment.CustomerEmail;
                appointmentFromDb.CustomerPhoneNumber = appDetailsVM.Appointment.CustomerPhoneNumber;
                appointmentFromDb.AppointmentDate     = appDetailsVM.Appointment.AppointmentDate;
                appointmentFromDb.IsConfirmed         = appDetailsVM.Appointment.IsConfirmed;

                //update sales associate if super admin
                if (User.IsInRole(StaticDetails.SuperAdminEndUser))
                {
                    appointmentFromDb.SalesAssociateId = appDetailsVM.Appointment.SalesAssociateId;
                }

                await _db.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }

            return(View(appDetailsVM));
        }
示例#8
0
        public async Task <IActionResult> Details(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var productList2 = (IEnumerable <Products>)(from p in _db.Products
                                                        join a in _db.ProductsSelectedForAppointment
                                                        on p.Id equals a.ProductId
                                                        where a.AppointmentId == id
                                                        select p).Include("ProductTypes").Include("Brand");

            var productList = (IEnumerable <ProductsSelectedForAppointment>)(from p in _db.Appointments
                                                                             join a in _db.ProductsSelectedForAppointment
                                                                             on p.Id equals a.AppointmentId
                                                                             where a.AppointmentId == id
                                                                             select a);
            AppointmentDetailsViewModel objAppointmentVM = new AppointmentDetailsViewModel()
            {
                Appointment = _db.Appointments.Include(a => a.SalesPerson).Where(a => a.Id == id).FirstOrDefault(),
                SalesPerson = _db.ApplicationUser.ToList(),
                ProductsSelectedForAppointments = productList.ToList(),
                Products = productList2.ToList()
            };

            return(View(objAppointmentVM));
        }
示例#9
0
        public async Task <IActionResult> EditUpdate(int?id, AppointmentDetailsViewModel objApplointmentVM)
        {
            if (id == null)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                var appointmentDb = await _db.Appointments.Where(a => a.ID == id).FirstOrDefaultAsync();

                appointmentDb.CustomerName    = objApplointmentVM.Appointment.CustomerName;
                appointmentDb.CustomerEmail   = objApplointmentVM.Appointment.CustomerEmail;
                appointmentDb.CustomerPhone   = objApplointmentVM.Appointment.CustomerPhone;
                appointmentDb.AppointmentDate = objApplointmentVM.Appointment.AppointmentDate.AddHours(objApplointmentVM.Appointment.AppointmentTime.Hour)
                                                .AddMinutes(objApplointmentVM.Appointment.AppointmentTime.Minute);

                appointmentDb.IsConfirmed = objApplointmentVM.Appointment.IsConfirmed;

                if (User.IsInRole(SD.SuperAdminEndUser))
                {
                    appointmentDb.SalesPersonID = objApplointmentVM.Appointment.SalesPersonID;
                }

                await _db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            else
            {
                return(View(objApplointmentVM));
            }
        }
        public async Task <IActionResult> Edit(int id, AppointmentDetailsViewModel objAppointmentVM)

        {
            if (ModelState.IsValid)
            {
                // build the date time from the two fields
                objAppointmentVM.Appointment.AppointmentDate = objAppointmentVM.Appointment.AppointmentDate
                                                               .AddHours(objAppointmentVM.Appointment.AppointmentTime.Hour)
                                                               .AddMinutes(objAppointmentVM.Appointment.AppointmentTime.Minute);

                // update database with any changed fields from input appointment screen.
                var appointmentFromDb = _db.Appointments.Where(a => a.Id == objAppointmentVM.Appointment.Id).FirstOrDefault();
                appointmentFromDb.CustomerName        = objAppointmentVM.Appointment.CustomerName;
                appointmentFromDb.CustomerEmail       = objAppointmentVM.Appointment.CustomerEmail;
                appointmentFromDb.CustomerPhoneNumber = objAppointmentVM.Appointment.CustomerPhoneNumber;
                appointmentFromDb.AppointmentDate     = objAppointmentVM.Appointment.AppointmentDate;
                appointmentFromDb.IsConfirmed         = objAppointmentVM.Appointment.IsConfirmed;

                if (User.IsInRole(SD.SuperAdminEndUser))
                {
                    appointmentFromDb.SalesPersonId = objAppointmentVM.Appointment.SalesPersonId;
                }

                _db.SaveChanges();
                return(RedirectToAction(nameof(Index)));
            }
            // model status not valid
            return(View(objAppointmentVM));
        }
示例#11
0
        public async Task <IActionResult> Edit(string id, AppointmentDetailsViewModel appDetailsVM)
        {
            if (ModelState.IsValid)
            {
                appDetailsVM.Appointment.AppointmentDate = appDetailsVM.Appointment.AppointmentDate
                                                           .AddHours(appDetailsVM.Appointment.AppointmentTime.Hour)
                                                           .AddMinutes(appDetailsVM.Appointment.AppointmentTime.Minute);

                var appFromDB = await _db.Appointments
                                .Where(p => p.Id == appDetailsVM.Appointment.Id)
                                .FirstOrDefaultAsync();

                appFromDB.CustomerName        = appDetailsVM.Appointment.CustomerName;
                appFromDB.CustomerEmail       = appDetailsVM.Appointment.CustomerEmail;
                appFromDB.CustomerPhoneNumber = appDetailsVM.Appointment.CustomerPhoneNumber;
                appFromDB.AppointmentDate     = appDetailsVM.Appointment.AppointmentDate;
                appFromDB.isConfirmed         = appDetailsVM.Appointment.isConfirmed;

                if (User.IsInRole(SD.AdminEndUser))
                {
                    appFromDB.SalesPersonId = appDetailsVM.Appointment.SalesPersonId;
                }

                await _db.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }

            return(View(appDetailsVM));
        }
示例#12
0
        // GET: AppointmentController/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var AppointmentProducts = db.ProductsSelectedForAppointments
                                      .Where(ap => ap.AppointmentId == id)
                                      .Include(ap => ap.Products).ThenInclude(p => p.ProductType)
                                      .Select(ap => ap.Products).ToList();


            //var AppointmentProducts = (from p in db.Products
            //                           join ap in db.ProductsSelectedForAppointments
            //                           on p.Id equals ap.ProductId
            //                           where ap.AppointmentId == id
            //                           select p).Include(product => product.ProductType).ToList();

            AppointmentDetailsViewModel objAppointmentVM = new AppointmentDetailsViewModel()
            {
                Appointment = db.Appointments.Include(a => a.SalesPerson).FirstOrDefault(a => a.Id == id),
                SalesPerson = db.ApplicationUser.ToList(),
                Products    = AppointmentProducts.ToList()
            };

            return(View(objAppointmentVM));
        }
示例#13
0
        public async Task <IActionResult> Edit(int id, AppointmentDetailsViewModel objAppointmentVM)
        {
            if (ModelState.IsValid)
            {
                objAppointmentVM.Appointment.AppointmentDate = objAppointmentVM.Appointment.AppointmentDate
                                                               .AddHours(objAppointmentVM.Appointment.AppointmentTime.Hour)
                                                               .AddMinutes(objAppointmentVM.Appointment.AppointmentTime.Minute);

                var appointmentFromDb = _db.Appointments.Where(a => a.Id == objAppointmentVM.Appointment.Id).FirstOrDefault();

                appointmentFromDb.CustomerName        = objAppointmentVM.Appointment.CustomerName;
                appointmentFromDb.CustomerEmail       = objAppointmentVM.Appointment.CustomerEmail;
                appointmentFromDb.CustomerPhoneNumber = objAppointmentVM.Appointment.CustomerPhoneNumber;
                appointmentFromDb.AppointmentDate     = objAppointmentVM.Appointment.AppointmentDate;
                appointmentFromDb.isConfirmed         = objAppointmentVM.Appointment.isConfirmed;
                if (User.IsInRole(SD.SuperAdminEndUser))
                {
                    appointmentFromDb.ApplicationUserId = objAppointmentVM.Appointment.ApplicationUserId;
                }
                _db.SaveChanges();

                return(RedirectToAction(nameof(Index)));
            }

            return(View(objAppointmentVM));
        }
示例#14
0
        // GET: AppointmentController/Create
        //public ActionResult Create()
        //{
        //    return View();
        //}
        #endregion

        #region Create Post
        //// POST: AppointmentController/Create
        //[HttpPost]
        //[ValidateAntiForgeryToken]
        //public ActionResult Create(IFormCollection collection)
        //{
        //    try
        //    {
        //        return RedirectToAction(nameof(Index));
        //    }
        //    catch
        //    {
        //        return View();
        //    }
        //}
        #endregion

        // GET: AppointmentController/Edit/5
        public async Task <ActionResult> Edit(int id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var AppointmentProducts = db.ProductsSelectedForAppointments
                                      .Where(ap => ap.AppointmentId == id)
                                      .Include(ap => ap.Products).ThenInclude(p => p.ProductType)
                                      .Select(ap => ap.Products).ToList();
            var users = db.ApplicationUser.ToList();
            List <ApplicationUser> salesPersons = new List <ApplicationUser>();

            foreach (var item in users)
            {
                if (await userManager.IsInRoleAsync(item, SD.AdminEndUser))
                {
                    salesPersons.Add(item);
                }
            }

            AppointmentDetailsViewModel objAppointmentVM = new AppointmentDetailsViewModel()
            {
                Appointment = db.Appointments.Include(a => a.SalesPerson).FirstOrDefault(a => a.Id == id),
                SalesPerson = salesPersons,
                //SalesPerson = db.ApplicationUser.ToList(),
                Products = AppointmentProducts.ToList()
            };

            return(View(objAppointmentVM));
        }
        public async Task <IActionResult> Edit(int?id)
        {
            if (id == null)
            {
                return(this.NotFound());
            }

            Appointment currentApp = this.db.Appointments.Include(a => a.SalesPerson).FirstOrDefault(a => a.Id == id);

            //Unclude only non-deleted users
            List <ApplicationUser> salesPeople = this.db.ApplicationUsers.Where(s => s.LockoutEnd == null).ToList();

            var productList = (IEnumerable <Product>)(from p in this.db.Products
                                                      join a in this.db.ProductsSelectedForAppointment
                                                      on p.Id equals a.ProductId
                                                      where a.AppointmentId == id
                                                      select p).Include("ProductTypes");

            AppointmentDetailsViewModel appVM = new AppointmentDetailsViewModel()
            {
                Appointment = currentApp,
                SalesPeople = salesPeople,
                Products    = productList.ToList()
            };

            return(this.View(appVM));
        }
        // Po umówieniu wizyty, Pacjent przechodzi do Podsumowania wizyty - AppointmentDetails
        public ViewResult AppointmentDetails(int id)
        {
            AppointmentDetailsViewModel appointmentDetailsViewModel = new AppointmentDetailsViewModel()
            {
                UserID      = userManager.GetUserId(User),
                Appointment = _appointmentRepository.GetAppointment(id),
                Doctor      = _doctorRepository.GetDoctor(id),
            };

            return(View(appointmentDetailsViewModel));
        }
示例#17
0
        public async Task <IActionResult> Delete(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            // retrieve IEnumerable of Products as List
            // JOIN Tables
            var productList = (IEnumerable <Products>)(from p in _colibriDbContext.Products
                                                       join a in _colibriDbContext.ProductsSelectedForAppointment
                                                       on p.Id equals a.ProductId
                                                       where a.AppointmentId == id
                                                       select p).Include("CategoryTypes");

            var userServicesList = (IEnumerable <UserServices>)(from s in _colibriDbContext.UserServices
                                                                join a in _colibriDbContext.UserServicesSelectedForAppointment
                                                                on s.Id equals a.UserServiceId
                                                                where a.AppointmentId == id
                                                                select s).Include("CategoryTypes");

            // use the ViewModel
            AppointmentDetailsViewModel appointmentViewModel = new AppointmentDetailsViewModel()
            {
                // retrieve the Appointment from the DB
                Appointment = await _colibriDbContext.Appointments
                              .Include(a => a.AppPerson)
                              .Where(a => a.Id == id)
                              .FirstOrDefaultAsync(),
                // get the Application User List
                AppPerson = _colibriDbContext.ApplicationUsers.ToList(),
                // get the List of all Products
                Products = productList.ToList(),
                // get the List of all Services
                UserServices = userServicesList.ToList()
            };

            // i18n
            ViewData["Delete"]              = _localizer["DeleteText"];
            ViewData["DeleteAppointment"]   = _localizer["DeleteAppointmentText"];
            ViewData["CustomerName"]        = _localizer["CustomerNameText"];
            ViewData["CustomerEmail"]       = _localizer["CustomerEmailText"];
            ViewData["CustomerPhoneNumber"] = _localizer["CustomerPhoneNumberText"];
            ViewData["AppointmentDate"]     = _localizer["AppointmentDateText"];
            ViewData["AppointmentTime"]     = _localizer["AppointmentTimeText"];
            ViewData["IsConfirmed"]         = _localizer["IsConfirmedText"];
            ViewData["UserName"]            = _localizer["UserNameText"];
            ViewData["Update"]              = _localizer["UpdateText"];
            ViewData["BackToList"]          = _localizer["BackToListText"];

            // return the ViewModel
            return(View(appointmentViewModel));
        }
        public IActionResult Details(int id)
        {
            var details = _unitOfWork.appoinmentRepository.GetAppointmentWithPatients(id);

            _logger.LogInformation(message: "{details} all details here", details.FirstOrDefault().Patient.Name);

            var appo = new AppointmentDetailsViewModel
            {
                Appointment = details.FirstOrDefault()
            };

            return(View(appo));
        }
示例#19
0
        public IActionResult Invoice(int id)
        {
            var productList = (IEnumerable <ProductsSelectedForAppointment>)(from p in _db.Appointments
                                                                             join a in _db.ProductsSelectedForAppointment
                                                                             on p.Id equals a.AppointmentId
                                                                             where a.AppointmentId == id
                                                                             select a);
            AppointmentDetailsViewModel objAppointmentVM = new AppointmentDetailsViewModel()
            {
                Appointment = _db.Appointments.Where(a => a.Id == id).FirstOrDefault(),
                ProductsSelectedForAppointments = productList.ToList()
            };

            //var model = _db.Appointments.SingleOrDefault(i=>i.Id.Equals(id));
            return(View(objAppointmentVM));
        }
        /// <summary>
        /// Action methos for appointments
        /// an email will also be sent upon cancellation
        /// </summary>
        /// <param name="id"></param>
        /// <param name="objAppointmentVM"></param>
        /// <returns></returns>
        public IActionResult Cancel(int id, AppointmentDetailsViewModel objAppointmentVM)
        {
            var appointment = _db.Appointments.FirstOrDefault(a => a.Id == id);

            objAppointmentVM.Appointment = appointment;


            objAppointmentVM.Appointment.isCancelled = true;
            objAppointmentVM.Appointment.isConfirmed = false;

            _db.SaveChanges();

            //await _emailSender.SendEmailAsync(_db.Users.Where(u => u.Id == claim.Value).FirstOrDefault().Email,
            //    "Open Properties - Your Appointment",
            //    "Your appointment was cancelled successfully");
            return(RedirectToAction(nameof(Index)));
        }
示例#21
0
        public ActionResult CreateAppointment(int patientId, int reservationId)
        {
            _appointmentService.Create(reservationId, patientId);

            var patient     = _patientRepo.Get(patientId);
            var reservation = _reservationRepo.Get(reservationId);
            var time        = _scheduleRepo.GetTime(reservation.DoctorAppointmentDateTimeId);
            var model       = new AppointmentDetailsViewModel
            {
                Doctor  = _doctorRepo.GetDoctorDetails(time.Schedule.DoctorId),
                Patient = patient,
                Date    = time.Schedule.Date,
                Time    = _scheduleService.FormatTime(time.Time)
            };

            return(View(model));
        }
示例#22
0
        //GET : Delete
        public async Task <IActionResult> Delete(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }
            var productList = (IEnumerable <Product>)(from p in _db.Products
                                                      join a in _db.ProductsSelectedForAppointments on p.Id equals a.ProductId
                                                      where a.AppointmentId == id
                                                      select p).Include("ProductType");
            AppointmentDetailsViewModel appointmentDetailsViewModel = new AppointmentDetailsViewModel()
            {
                Appointment  = await _db.Appointments.Where(a => a.Id == id).Include(a => a.SalesPerson).FirstOrDefaultAsync(),
                SalesPersons = await _db.ApplicationUsers.ToListAsync(),
                Products     = productList.ToList()
            };

            return(View(appointmentDetailsViewModel));
        }
        public async Task <IActionResult> Edit(int id, AppointmentDetailsViewModel objAppointmentVM)
        {
            if (ModelState.IsValid)
            {
                objAppointmentVM.Appointment.AppointmentDate = objAppointmentVM.Appointment.AppointmentDate
                                                               .AddHours(objAppointmentVM.Appointment.AppointmentTime.Hour)
                                                               .AddMinutes(objAppointmentVM.Appointment.AppointmentTime.Minute);

                var appointmentFromDb = _db.Appointments.Where(a => a.Id == objAppointmentVM.Appointment.Id).FirstOrDefault();

                appointmentFromDb.CustomerName        = objAppointmentVM.Appointment.CustomerName;
                appointmentFromDb.CustomerEmail       = objAppointmentVM.Appointment.CustomerEmail;
                appointmentFromDb.AppointmentDate     = objAppointmentVM.Appointment.AppointmentDate;
                appointmentFromDb.CustomerPhoneNumber = objAppointmentVM.Appointment.CustomerPhoneNumber;
                appointmentFromDb.IsConfirmed         = objAppointmentVM.Appointment.IsConfirmed;

                if (User.IsInRole(SD.SuperAdminEndUser))
                {
                    appointmentFromDb.SalesPersonId = objAppointmentVM.Appointment.SalesPersonId;
                }
                else
                {
                    appointmentFromDb.SalesPersonId = "";
                }

                _db.SaveChanges();

                return(RedirectToAction(nameof(Index)));
            }
            else
            {
                var productList = (IEnumerable <Products>)(from p in _db.Products
                                                           join a in _db.ProductsSelectedForAppointment
                                                           on p.Id equals a.ProductId
                                                           where a.AppointmentId == id
                                                           select p).Include("ProductTypes");

                objAppointmentVM.SalesPerson = _db.ApplicationUsers.Where(u => u.LockoutEnd == null || u.LockoutEnd < DateTime.Now).ToList();
                objAppointmentVM.Products    = productList.ToList();
            }

            return(View(objAppointmentVM));
        }
示例#24
0
        public async Task <IActionResult> Edit(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }
            var sanhamList = (IEnumerable <ThongTinSanPham>)(from p in _db.ThongTinSanPham
                                                             join a in _db.ProductsSelectedForAppointment
                                                             on p.Id equals a.Id
                                                             where a.AppointmentId == id
                                                             select p).Include("SanPham");
            AppointmentDetailsViewModel objAppointmentVM = new AppointmentDetailsViewModel()
            {
                Appointment  = _db.Appointments.Include(a => a.NguoiBanHang).Where(a => a.Id == id).FirstOrDefault(),
                NguoiBanHang = _db.ApplicationUser.ToList(),
                SanPham      = sanhamList.ToList()
            };

            return(View(objAppointmentVM));
        }
示例#25
0
        public async Task <IActionResult> Edit(int id, AppointmentDetailsViewModel objappoint)
        {
            if (ModelState.IsValid)
            {
                var appointmentfromdb = _db.Appointments.Where(a => a.Id == objappoint.Appointments.Id).FirstOrDefault();

                appointmentfromdb.CustomerName        = objappoint.Appointments.CustomerName;
                appointmentfromdb.CustomerEmail       = objappoint.Appointments.CustomerEmail;
                appointmentfromdb.CustomerPhoneNumber = objappoint.Appointments.CustomerPhoneNumber;
                appointmentfromdb.AppointmentDate     = objappoint.Appointments.AppointmentDate;
                appointmentfromdb.isConfirmed         = objappoint.Appointments.isConfirmed;

                if (User.IsInRole(SD.SuperAdminEndUser))
                {
                    appointmentfromdb.SalesPersonId = objappoint.Appointments.SalesPersonId;
                }
                _db.SaveChanges();
                return(RedirectToAction(nameof(Index)));
            }
            return(View(objappoint));
        }
示例#26
0
        //Get action method for appointment
        public async Task <IActionResult> Edit(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var productList = (IEnumerable <Products>)(from p in _context.Products
                                                       join x in _context.ProductsAppointments
                                                       on p.Id equals x.ProductId
                                                       where x.AppointmentId == id
                                                       select p).Include("ProductTypes");
            var appointmentDetailsViewModel = new AppointmentDetailsViewModel
            {
                Appointment = _context.Appointments.Include(a => a.SalesPerson).Where(z => z.Id == id).FirstOrDefault(),
                SalesPerson = _context.ApplicationUser.ToList(),
                Products    = productList.ToList()
            };

            return(View(appointmentDetailsViewModel));
        }
示例#27
0
        // GET: Appointments/Details/5
        public async Task <IActionResult> Details(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var appointment = await _context.Appointment
                              .Include(a => a.Dependent)
                              .Include(a => a.Doctor)
                              .SingleOrDefaultAsync(m => m.AppointmentId == id);

            if (appointment == null)
            {
                return(NotFound());
            }
            var model = new AppointmentDetailsViewModel();

            model.Appointment = appointment;
            return(View(model));
        }
示例#28
0
        //Get Edit action
        public async Task <IActionResult> Edit(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var productList = (IEnumerable <Products>)(from p in _db.Products
                                                       join a in _db.ProductSelectedForAppointments
                                                       on p.Id equals a.ProductsId
                                                       where a.AppointmentsId == id
                                                       select p).Include("ProductTypes");//this is a link method that brings the products selected by a particular appointment
            AppointmentDetailsViewModel objAppointmentVM = new AppointmentDetailsViewModel()
            {
                Appointments = _db.Appointments.Include(m => m.SalesPerson).Where(a => a.Id == id).FirstOrDefault(),
                SalesPerson  = _db.ApplicationUser.ToList(),
                Products     = productList.ToList()
            };

            return(View(objAppointmentVM));
        }
示例#29
0
        public ActionResult Edit(int id, AppointmentDetailsViewModel appointmentvm)
        {
            //try
            //{


            //}
            //catch
            //{
            //    return View();
            //}


            if (ModelState.IsValid)
            {
                appointmentvm.Appointment.AppointmentDate = appointmentvm.Appointment.AppointmentDate
                                                            .AddHours(appointmentvm.Appointment.AppointmentTime.Hour)
                                                            .AddMinutes(appointmentvm.Appointment.AppointmentTime.Minute);


                //var appointmentFromDb = db.Appointments.Where(a => a.Id == appointmentvm.Appointment.Id).FirstOrDefault();


                //appointmentFromDb.CustomerName = appointmentvm.Appointment.CustomerName;
                //appointmentFromDb.CustomerEmail = appointmentvm.Appointment.CustomerEmail;
                //appointmentFromDb.CustomerPhoneNumber = appointmentvm.Appointment.CustomerPhoneNumber;
                //appointmentFromDb.AppointmentDate = appointmentvm.Appointment.AppointmentDate;
                //appointmentFromDb.isConfirmed = appointmentvm.Appointment.isConfirmed;
                ////if (User.IsInRole(SD.SuperAdminEndUser))
                ////{
                //    appointmentFromDb.SalesPersonId = appointmentvm.Appointment.SalesPersonId;
                //}

                db.Entry <Appointment>(appointmentvm.Appointment).State = EntityState.Modified;
                db.SaveChanges();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(appointmentvm));
        }
示例#30
0
        //GET Detials
        public async Task <IActionResult> Details(string id)
        {
            if (string.IsNullOrEmpty(id))
            {
                return(NotFound());
            }

            var productList = (IEnumerable <Products>)(from p in _db.Products
                                                       join a in _db.ProductsSelectedForAppointment
                                                       on p.Id equals a.ProductId
                                                       where a.AppointmentId == id
                                                       select p).Include("ProductTypes");

            AppointmentDetailsViewModel appDetailsVM = new AppointmentDetailsViewModel()
            {
                Appointment = await _db.Appointments.Include(a => a.SalesPerson).Where(a => a.Id == id).FirstOrDefaultAsync(),
                SalesPerson = await _db.ApplicationUser.ToListAsync(),
                Products    = productList.ToList()
            };

            return(View(appDetailsVM));
        }
 public AppointmentDetailsView( AppointmentDetailsViewModel appointmentDetailsViewModel )
     : this()
 {
     DataContext = appointmentDetailsViewModel;
 }