예제 #1
0
        // GET: SportEvent
        public ActionResult Index()
        {
            SportEventListViewModel viewModel = new SportEventListViewModel();

            viewModel.SportEventList = SportEventRepository.GetAllSportEvents();
            SetEnumDDisciplineSelectList(true);

            return(View(viewModel));
        }
예제 #2
0
        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));
        }
예제 #3
0
        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));
        }
예제 #4
0
        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." }));
        }
예제 #5
0
        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));
        }
예제 #6
0
 public SportEventController(SportEventRepository sportEventRepository, IWebHostEnvironment hostEnvironment)
 {
     _SportEventRepository = sportEventRepository;
     this._hostEnvironment = hostEnvironment;
 }
예제 #7
0
 public EventService(SportEventRepository sportEventRepository, IHttpContextAccessor httpContextAccessor)
 {
     _sportEventRepository = sportEventRepository;
     _httpContextAccessor  = httpContextAccessor;
 }