public ActionResult AddAppointment(AddAppointmentViewModel viewModel)
        {
            if (appointmentsService.IsValidModelState())
            {
                Appointment appointment = new Appointment();

                double          summedMinutes = 0;
                List <Activity> activities    = activitiesService.GetAll(a => viewModel.CheckedRows.Contains(a.ActivityId)).ToList();
                foreach (Activity activity in activities)
                {
                    summedMinutes += activity.Duration;
                    appointment.Activities.Add(activity);
                }

                DateTime startDateTime = viewModel.StartDateTime;
                appointment.StartDateTime = startDateTime;
                TimeSpan summedDuration = TimeSpan.FromMinutes(summedMinutes);
                DateTime endDateTime    = startDateTime.Add(summedDuration);
                appointment.EndDateTime = endDateTime;
                appointment.UserId      = LoginUserSession.Current.UserId;
                bool hasSavedSuccessfully = appointmentsService.Add(appointment);
                if (hasSavedSuccessfully)
                {
                    TempData["SuccessfullMessage"] = "Appointment added successfully";
                    return(RedirectToAction("ViewAppointments", "Appointments"));
                }
                else
                {
                    TempData["ErrorMessage"] = "There was a server error while adding the appointment.";
                    return(RedirectToAction("Index", "Home"));
                }
            }

            return(View(viewModel));
        }