public ActionResult Index() { try { User currentUser = BusinessLayer.UserBusiness.Get(HttpContext.User.Identity.Name); var allSuggestions = SuggestionBusiness.GetAll(); Suggestion selectedSuggestion = null; if (allSuggestions.Count > 0) { selectedSuggestion = allSuggestions[0]; selectedSuggestion.JoinedUsers = SuggestionBusiness.GetJoinedUsers(selectedSuggestion.Id); } var viewModel = new DashboardViewModel() { AllSuggestions = allSuggestions, SelectedSuggestion = selectedSuggestion == null ? null : SuggestionViewModel.FromModel(selectedSuggestion), JoinedSuggestions = SuggestionBusiness.GetByUser(currentUser.Id), OwnedSuggestions = SuggestionBusiness.GetByCreator(currentUser.Id) }; return View(viewModel); } catch (Exception e) { return View("Error", ErrorHelper.ErrorModelForDomainException(e)); } }
public ActionResult Close(int id) { int userId = BusinessLayer.UserBusiness.Get(HttpContext.User.Identity.Name).Id; BusinessLayer.SuggestionBusiness.Close(id, userId); var model = new DashboardViewModel { AllSuggestions = SuggestionBusiness.GetAll(), OwnedSuggestions = SuggestionBusiness.GetByCreator(userId), JoinedSuggestions = SuggestionBusiness.GetByUser(userId) }; return PartialView("_SuggestionTable", model); }
public ActionResult Join(int id, Weekdays weekdays) { try { Suggestion suggestion = BusinessLayer.SuggestionBusiness.Get(id); int userId = BusinessLayer.UserBusiness.Get(HttpContext.User.Identity.Name).Id; BusinessLayer.SuggestionBusiness.Join(userId, id, weekdays.ToString()); //get updated location suggestion.Location = BusinessLayer.SuggestionBusiness.Get(id).Location; suggestion.JoinedUsers = BusinessLayer.SuggestionBusiness.GetJoinedUsers(suggestion.Id); var model = new DashboardViewModel { SelectedSuggestion = SuggestionViewModel.FromModel(suggestion) }; return PartialView("_SuggestionDetails", model.SelectedSuggestion); } catch(DomainException e) { return View("Error"); }; }
public ActionResult GetSuggestion(int id) { Suggestion suggestion; try { suggestion = BusinessLayer.SuggestionBusiness.Get(id); suggestion.JoinedUsers = BusinessLayer.SuggestionBusiness.GetJoinedUsers(suggestion.Id); } catch (DomainException e) { return View("Error", ErrorHelper.ErrorModelForDomainException(e)); } var model = new DashboardViewModel { SelectedSuggestion = SuggestionViewModel.FromModel(suggestion) }; return PartialView("_SuggestionDetails", model.SelectedSuggestion); }