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)); }
//// POST: api/Activities //[HttpPost] public Result Add(Activities activity) { var result = new Result(); try { ActivitiesService.Add(activity.ActivityTypeValue, activity.EntryType, activity.SourceType, activity.UserName, string.Empty, activity.HostName); result.IsSuccess = true; } catch (Exception exception) { result.IsSuccess = false; //result.ExceptionInfo = new ExceptionInfo(exception); } return(result); }