Exemplo n.º 1
0
        public ActionResult DeleteFootballTeam(int footballTeamId)
        {
            FootballTeamViewModel vm = _adminService.GetFootballTeamViewById(footballTeamId);

            vm.PreviousLink = this.Url.Action("FootballTeams", "Admin", this.Request.Url.Scheme);

            return(View(vm));
        }
Exemplo n.º 2
0
        public int AddFootballTeam(FootballTeamViewModel model)
        {
            FootballTeam footballTeam = AutoMapper.Mapper.Map <FootballTeam>(model);

            UnitOfWork.FootballTeams.Add(footballTeam);
            UnitOfWork.SaveChanges();

            return(footballTeam.Id);
        }
Exemplo n.º 3
0
        public ActionResult AddFootballTeam()
        {
            FootballTeamViewModel footballTeamVm = new FootballTeamViewModel();

            footballTeamVm.PreviousLink = this.Url.Action("FootballTeams", "Admin", this.Request.Url.Scheme);

            ViewBag.Locations = _adminService.GetLocations(LocationType.All);

            return(View(footballTeamVm));
        }
Exemplo n.º 4
0
        public ActionResult AddFootballTeam(FootballTeamViewModel model)
        {
            if (!ModelState.IsValid)
            {
                ViewBag.Locations  = _adminService.GetLocations(LocationType.All);
                model.PreviousLink = this.Url.Action("FootballTeams", "Admin", this.Request.Url.Scheme);

                return(View(model));
            }

            int teamId = _adminService.AddFootballTeam(model);

            return(RedirectToAction("EditFootballTeam", new { footballTeamId = teamId }));
        }
Exemplo n.º 5
0
        public ActionResult EditFootballTeam([Bind(Include = "Id, Name, EmblemImageUrl, IsActive, LocationId")] FootballTeamViewModel model)
        {
            if (!ModelState.IsValid)
            {
                ViewBag.Locations        = _adminService.GetLocations(LocationType.All);
                ViewBag.CompetitionTypes = _adminService.GetCompetitionTypes();
                model.PreviousLink       = this.Url.Action("FootballTeams", "Admin", this.Request.Url.Scheme);

                return(View(model));
            }

            _adminService.UpdateFootballTeam(model);

            return(EditFootballTeam(model.Id));
        }
Exemplo n.º 6
0
        public void UpdateFootballTeam(FootballTeamViewModel model)
        {
            FootballTeam footballTeam = UnitOfWork.FootballTeams.FirstOrDefault(x => x.Id == model.Id);

            if (footballTeam == null)
            {
                throw new ArgumentNullException("There is no such item in database");
            }

            footballTeam.Name           = model.Name;
            footballTeam.EmblemImageUrl = model.EmblemImageUrl;
            //footballTeam.IsDeleted = model.IsDeleted;
            footballTeam.LocationId = model.LocationId;
            //footballTeam.CDate = DateTime.Now;

            UnitOfWork.SaveChanges();
        }
Exemplo n.º 7
0
        public ActionResult DeleteFootballTeam([Bind(Include = "Id, Name, EmblemImageUrl, IsActive")] FootballTeamViewModel model)
        {
            _adminService.DeleteFootballTeam(model.Id);

            return(RedirectToAction("FootballTeams"));
        }