public ActionResult AddActivity(AddActivityViewModel viewModel) { if (activitiesService.IsValidModelState()) { Activity activity = new Activity(); activity.ActivityId = 0; activity.Duration = viewModel.Duration; activity.Name = viewModel.Name; activity.Price = viewModel.Price; if (activitiesService.IsExistingActivity(a => a.Name == activity.Name)) { return(View(viewModel)); } bool hasSuccessfullySaved = activitiesService.Add(activity); if (hasSuccessfullySaved) { TempData["SuccessfullMessage"] = "Activity added successfully!"; return(RedirectToAction("ViewActivities", "Activities")); } else { TempData["ErrorMessage"] = "There was a server error during the save of the activity. Try again!"; return(RedirectToAction("Index", "Home")); } } return(View(viewModel)); }