Exemplo n.º 1
0
        public ActionResult Create(AppointmentCreateViewModel Vmodel, Appointment model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            //Appointment appointment = new Appointment();

            model.StartDateTime = Convert.ToDateTime(Vmodel.StartDateTime);

            model.UserId = Authentication.AuthenticationManager.LoggedUser.Id;
            List <Activity> ac = new List <Activity>();
            List <string>   activitiesForEmail = new List <string>();

            foreach (var item in Vmodel.ListBoxActivities)
            {
                if (item.IsChecked)
                {
                    ac.Add(activityService.Get(item.Id));
                }
            }
            foreach (var item in ac)
            {
                activitiesForEmail.Add(item.Name);
            }
            model.Activities  = ac;
            model.EndDateTime = model.StartDateTime.AddHours(ac.Sum(a => a.Duration));

            if (!service.Insert(model))
            {
                return(View(Vmodel));
            }
            emailSend.SendNewAppointmentEmail(Authentication.AuthenticationManager.LoggedUser, activitiesForEmail, model);
            return(RedirectToAction("Index"));
        }
Exemplo n.º 2
0
        public async Task <ActionResult> Create(AppointmentCreateViewModel model)
        {
            if (User.Identity.IsAuthenticated)
            {
                ModelState.Remove(nameof(model.ClientName));
                ModelState.Remove(nameof(model.ClientPhoneNumber));
                ModelState.Remove(nameof(model.ClientEmail));
            }

            if (!ModelState.IsValid)
            {
                return(Json(ModelState.ToDictionary()));
            }

            int appointmentId;

            if (User.Identity.IsAuthenticated)
            {
                appointmentId = await appointmentsManager.Create(new AppointmentCreateDTO(model), User.Identity.GetUserId());
            }
            else
            {
                appointmentId = await appointmentsManager.Create(new AppointmentCreateDTO(model), new NonRegisteredUserCreateDTO(model));
            }

            return(Json(appointmentId));
        }
Exemplo n.º 3
0
        public ActionResult Create()
        {
            if (Authentication.AuthenticationManager.LoggedUser == null)
            {
                return(RedirectToAction("Login", "Account"));
            }
            else
            {
                IEnumerable <Activity>     activities = activityService.GetAll();
                List <ActivityViewModel>   model      = new List <ActivityViewModel>();
                AppointmentCreateViewModel Vmodel     = new AppointmentCreateViewModel();

                foreach (var activity in activities)
                {
                    ActivityViewModel viewModel = new ActivityViewModel
                    {
                        Id       = activity.Id,
                        Name     = activity.Name,
                        Duration = activity.Duration,
                        Price    = activity.Price
                    };
                    model.Add(viewModel);
                    Vmodel.ListBoxActivities = model;
                }
                return(View(Vmodel));
            }
        }
        public IActionResult Create(AppointmentCreateViewModel model)
        {
            string error = null;

            if (ModelState.IsValid)
            {
                try
                {
                    _unitOfWork.Appointments.Add(model.Appointment);
                    _unitOfWork.Save();

                    return(RedirectToAction("Feed", "Employees", new
                    {
                        employeeId = model.Appointment.EmployeeId,
                        buttonClicked = model.ButtonClicked,
                        priority = model.Priority,
                        error = GenerateDashboardDisplay(model.Appointment, model.Appointment.EmployeeId)
                    }));
                }
                catch (ValidationException validationException)
                {
                    ValidationResult valResult = validationException.ValidationResult;
                    ModelState.AddModelError(nameof(model) + "." + valResult.MemberNames.First(), valResult.ErrorMessage);
                }
            }

            return(View(model));
        }
        public ActionResult Create(AppointmentCreateViewModel model, string redirectUrl)
        {
            if (!ModelState.IsValid)
            {
                var dentists = UserManager.Users.Where(x => x.TypeUser == UserType.Dentist).Select(t => new SelectListItem
                {
                    Text  = t.FirstName + " " + t.LastName + " " + t.MiddleName,
                    Value = (t.Id).ToString()
                }).ToList();

                var patients = Patients.Get().Select(s => new SelectListItem
                {
                    Text  = s.LastName + " " + s.FirstName + " " + s.MiddleName,
                    Value = Convert.ToString(s.PatientsId)
                }).ToList();

                model.Users    = patients;
                model.Patients = dentists;
                return(View(model));
            }


            var app = new Appointments
            {
                PatientId         = model.PatientId,
                UserId            = model.UserId,
                AppointmentStatus = Status.Pending,
                VisitDate         = model.VisitDate
            };

            Appointment.Create(app);

            return(RedirectToLocal(redirectUrl));
        }
Exemplo n.º 6
0
        public ActionResult Create([Bind(Exclude = "SelectedActivities")] AppointmentCreateViewModel model, string[] selectedActivities)
        {
            //if (ModelState.IsValid)
            {
                AppointmentRepository repository  = new AppointmentRepository();
                Appointment           appointment = new Appointment();
                appointment.UserId        = UserController.UserId;
                appointment.StartDateTime = model.StartDateTime;



                appointment.Activities = GetSelectedActivities(selectedActivities, repository);

                foreach (var item in appointment.Activities)
                {
                    time += item.Duration;
                }
                appointment.EndDateTime = model.StartDateTime.AddHours(time);
                repository.Insert(appointment);

                return(RedirectToAction("AppointmentList"));
            }
            //else
            //{
            //    return View(model);
            //}\\
        }
Exemplo n.º 7
0
        /// <summary>
        /// Appointment Edit GET Method
        /// </summary>
        /// <param name="id">Appoinment Identifier</param>
        /// <returns></returns>
        public IActionResult Edit(string id)
        {
            Appointment appointment = _appointmentService.GetById(id);

            if (appointment == null)
            {
                return(RedirectToAction("NotFound", "Error"));
            }

            List <SelectListItem> customerList = _customerService.GetList().Select(c => new SelectListItem
            {
                Value = c.Id,
                Text  = $"{c.Name} {c.LastName} ({c.PhoneNumber})"
            }).ToList();

            AppointmentCreateViewModel vm = new AppointmentCreateViewModel
            {
                CustomerList    = customerList,
                AppointmentDate = appointment.AppointmentDate,
                CustomerId      = appointment.CustomerId,
                Description     = appointment.Note
            };

            return(View(vm));
        }
Exemplo n.º 8
0
        // GET: Appointments/Create
        public async Task <IActionResult> Create()
        {
            ApplicationUser user = await GetCurrentUserAsync();

            var model = new AppointmentCreateViewModel(_context, user);

            return(View(model));
        }
        public IActionResult Create(int employeeId, string buttonClicked, bool priority)
        {
            AppointmentCreateViewModel model = new AppointmentCreateViewModel();

            model.LoadData(_unitOfWork, employeeId);
            model.ButtonClicked = buttonClicked;
            model.Priority      = priority;
            return(View(model));
        }
Exemplo n.º 10
0
        public PartialViewResult CreateAppointment(int caseId, int providerId, DateTime date)
        {
            var model = new AppointmentCreateViewModel()
            {
                CaseId     = caseId,
                ProviderId = providerId,
                Date       = date
            };

            return(PartialView("AppointmentCreatePopUp", model));
        }
Exemplo n.º 11
0
        /// <summary>
        /// Appointment Create GET Method
        /// </summary>
        /// <returns></returns>
        public IActionResult Create()
        {
            List <SelectListItem> customerList = _customerService.GetList().Select(c => new SelectListItem
            {
                Value = c.Id,
                Text  = $"{c.Name} {c.LastName} ({c.PhoneNumber})"
            }).ToList();

            AppointmentCreateViewModel vm = new AppointmentCreateViewModel
            {
                CustomerList    = customerList,
                AppointmentDate = null
            };

            return(View(vm));
        }
Exemplo n.º 12
0
        public IActionResult Edit(string id, AppointmentCreateViewModel model)
        {
            Appointment appointment = _appointmentService.GetById(id);

            if (appointment == null)
            {
                return(RedirectToAction("NotFound", "Error"));
            }

            appointment.AppointmentDate = model.AppointmentDate.Value;
            appointment.Note            = model.Description;
            appointment.CustomerId      = model.CustomerId;

            _appointmentService.Update(appointment);

            return(RedirectToAction("Index"));
        }
Exemplo n.º 13
0
        public IActionResult Create(AppointmentCreateViewModel model)
        {
            if (ModelState.IsValid == false)
            {
                return(RedirectToAction("BadRequest", "Error"));
            }

            Appointment app = new Appointment
            {
                AppointmentDate = model.AppointmentDate.Value,
                CustomerId      = model.CustomerId,
                Note            = model.Description,
                WorkerId        = User.Claims.FirstOrDefault(x => x.Type == "Id").Value
            };

            _appointmentService.Insert(app);

            return(RedirectToAction("Index"));
        }
Exemplo n.º 14
0
        public ActionResult Edit(int?id)
        {
            AppointmentRepository      repository  = new AppointmentRepository();
            Appointment                appointment = repository.GetById(id);
            AppointmentCreateViewModel model       = new AppointmentCreateViewModel();

            model.UserId        = appointment.UserId;
            model.StartDateTime = appointment.StartDateTime;

            ActivityRepository activityRepo = new ActivityRepository();
            List <Activity>    act          = activityRepo.GetAll();
            int counter = -1;

            model.SelectedActivities = new List <SelectListItem>();
            foreach (var activity in act)
            {
                counter++;
                model.SelectedActivities.Add(new SelectListItem
                {
                    Text     = activity.Name,
                    Value    = activity.Id.ToString(),
                    Selected = false
                });

                foreach (var item in appointment.Activities)
                {
                    if (activity.Id == item.Id)
                    {
                        model.SelectedActivities[counter].Selected = true;
                        break;
                    }
                }
            }

            if (appointment == null)
            {
                return(HttpNotFound());
            }
            return(View(model));
        }
        public ActionResult Create()
        {
            var dentists = UserManager.Users.Where(x => x.TypeUser == UserType.Dentist).Select(t => new SelectListItem
            {
                Text  = t.FirstName + " " + t.LastName + " " + t.MiddleName,
                Value = t.Id
            }).ToList();

            var patients = Patients.Get().Select(s => new SelectListItem
            {
                Text  = s.LastName + " " + s.FirstName + " " + s.MiddleName,
                Value = Convert.ToString(s.PatientsId)
            }).ToList();

            var model = new AppointmentCreateViewModel
            {
                Users    = dentists,
                Patients = patients
            };

            return(View(model));
        }
Exemplo n.º 16
0
        public ActionResult Create()
        {
            ActivityRepository         repository           = new ActivityRepository();
            AppointmentCreateViewModel appointmentViewModel = new AppointmentCreateViewModel();

            appointmentViewModel.StartDateTime = DateTime.Now;
            appointmentViewModel.EndDateTime   = DateTime.Now;

            List <Activity> activities = repository.GetAll();

            appointmentViewModel.SelectedActivities = new List <SelectListItem>();
            foreach (var activity in activities)
            {
                appointmentViewModel.SelectedActivities.Add(new SelectListItem
                {
                    Text     = activity.Name,
                    Value    = activity.Id.ToString(),
                    Selected = false
                });
            }
            //appointmentViewModel.Activities = repository.GetAll();

            return(View(appointmentViewModel));
        }