示例#1
0
        public ActionResult Add()
        {
            ViewBag.teamsList  = ItemListCreator.Teams(_teamRepo);
            ViewBag.sportsList = ItemListCreator.Sports();

            return(View());
        }
示例#2
0
        public ActionResult Add(Athlete athlete)
        {
            ViewBag.teamsList  = ItemListCreator.Teams(_teamRepo);
            ViewBag.sportsList = ItemListCreator.Sports();

            if (ModelState.IsValid)
            {
                if (_athRepo.Add(athlete))
                {
                    ViewBag.Success = "Added succesfully";
                    return(View());
                }
            }

            ViewBag.Error = "Error adding an athlete!";
            return(View());
        }
示例#3
0
        public ActionResult Update(int id)
        {
            Athlete athlete = _athRepo.GetById((int)id);

            var teamsList = ItemListCreator.Teams(_teamRepo);

            teamsList.ElementAt(0).Selected = false;
            teamsList.Where(item => item.Text == athlete.TeamName).First().Selected = true;
            ViewBag.teamsList = teamsList;


            var sportsList = ItemListCreator.Sports();

            sportsList.Where(sport => sport.Text == athlete.Sport).First().Selected = true;
            sportsList.ElementAt(0).Selected = false;
            ViewBag.sportsList = sportsList;

            return(View(athlete));
        }
示例#4
0
        public ActionResult Add(EventViewModel ev)
        {
            ViewBag.sportsList   = ItemListCreator.Sports();
            ViewBag.teamsList    = ItemListCreator.Teams(_teamRepo);
            ViewBag.athletesList = ItemListCreator.Athletes(_athRepo);

            if (ModelState.IsValid)
            {
                EventDTO eventDTO = Mapper.Map <EventViewModel, EventDTO>(ev);
                if (_eventRepo.Add(eventDTO))
                {
                    ViewBag.Success = "Added succesfully";
                    return(View());
                }
            }

            ViewBag.Error = "Error adding an event!";
            return(View());
        }