public ActionResult AddAppointment() { IEnumerable <Activity> dbActivities = activitiesService.GetAll(); List <ActivityRow> activityRows = new List <ActivityRow>(); AddAppointmentViewModel viewModel = new AddAppointmentViewModel(); DateTime currentTime = DateTime.Now; viewModel.StartDateTime = currentTime; viewModel.EndDateTime = currentTime; foreach (Activity activity in dbActivities) { ActivityRow activityRow = new ActivityRow(); activityRow.activity = activity; activityRow.isChecked = false; activityRows.Add(activityRow); } viewModel.activityRows = activityRows; return(View(viewModel)); }
public ActionResult ViewActivities() { IEnumerable <Activity> activities = activitiesService.GetAll(); List <ViewActivitiesViewModel> viewModels = new List <ViewActivitiesViewModel>(); foreach (Activity activity in activities) { ViewActivitiesViewModel viewModel = new ViewActivitiesViewModel(); viewModel.ActivityId = activity.ActivityId; viewModel.Duration = activity.Duration; viewModel.Name = activity.Name; viewModel.Price = activity.Price; viewModels.Add(viewModel); } return(View(viewModels)); }