// GET: SportEvent public ActionResult Index() { SportEventListViewModel viewModel = new SportEventListViewModel(); viewModel.SportEventList = SportEventRepository.GetAllSportEvents(); SetEnumDDisciplineSelectList(true); return(View(viewModel)); }
public ActionResult AddSportEvent(SportEventModel model) { if (SportEventRepository.AddSportEvent(model)) { ViewBag.SuccessMessages = "Wydarzenie zostało utworzone pomyślnie"; } else { ViewBag.ErrorMessages = SportEventRepository.ErrorList; } SportEventListViewModel viewModel = new SportEventListViewModel(); viewModel.SportEventList = SportEventRepository.GetAllSportEvents(); SetEnumDDisciplineSelectList(true); return(View("Index", viewModel)); }
public ActionResult PreviewSportEvent(int sportEventId) { int userIdFromContext = UserContextHelper.GetUserContextModel().ID; SportEventModel model = SportEventRepository.GetSportEventDetails(sportEventId); DateTime sportEventDateTime = DateTime.Parse(model.Date + " " + model.Time); var differenceHours = (sportEventDateTime - DateTime.Now).TotalHours; if (differenceHours < 1) { model.ContactList = SportEventRepository.GetContactDetailsForSportEvent(sportEventId, userIdFromContext); } model.IsCreateMode = false; SetEnumDDisciplineSelectList(false); TempData["IsUserParticipating"] = SportEventRepository.IsUserParticipatingInSportEvent(userIdFromContext, sportEventId); return(View("SportEvent", model)); }
public JsonResult JoinSportEvent(int userId, int sportEventId, bool join) { bool result = SportEventRepository.ChangeUserParticipationStatusInSportEvent(userId, sportEventId, join); if (result) { if (join) { return(Json(new { Status = "Added", Result = "Zapisałeś się do wydarzenia." })); } else { return(Json(new { Status = "Removed", Result = "Wypisałeś się z wydarzenia." })); } } else if (result == false && SportEventRepository.ErrorList.Count > 0) { return(Json(new { Status = "Error", Result = SportEventRepository.ErrorList.First() })); } return(Json(new { Status = "Error", Result = "Wystąpił błąd." })); }
public ActionResult SportEventListFiltered(SportEventListViewModel viewModel) { SortedList <string, string> paramDictionary = new SortedList <string, string>(); if (viewModel.DDiscipline != 0) { paramDictionary.Add("DDisciplineID", EnumHelpers.GetDescriptionOfEnum(ComparisionEnum.Equal) + " " + (int)viewModel.DDiscipline); } if (!string.IsNullOrWhiteSpace(viewModel.EventDate)) { paramDictionary.Add("Date", EnumHelpers.GetDescriptionOfEnum(ComparisionEnum.Equal) + " '" + viewModel.EventDate + "'"); } if (!string.IsNullOrWhiteSpace(viewModel.EventTime)) { paramDictionary.Add("Time", EnumHelpers.GetDescriptionOfEnum(ComparisionEnum.GreaterEqual) + " '" + viewModel.EventTime + "'"); } paramDictionary.Add("HasEnded", EnumHelpers.GetDescriptionOfEnum(ComparisionEnum.Equal) + " 0"); viewModel.SportEventList = SportEventRepository.GetSportEventsFiltered(paramDictionary); SetEnumDDisciplineSelectList(true); return(View("Index", viewModel)); }
public SportEventController(SportEventRepository sportEventRepository, IWebHostEnvironment hostEnvironment) { _SportEventRepository = sportEventRepository; this._hostEnvironment = hostEnvironment; }
public EventService(SportEventRepository sportEventRepository, IHttpContextAccessor httpContextAccessor) { _sportEventRepository = sportEventRepository; _httpContextAccessor = httpContextAccessor; }