Ejemplo n.º 1
0
        public ActionResult DeleteFootballPlayer(int footballPlayerId)
        {
            FootballPlayerViewModel vm = _adminService.GetFootballPlayerViewById(footballPlayerId);

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

            return(View(vm));
        }
Ejemplo n.º 2
0
        public ActionResult AddFootballPlayer()
        {
            FootballPlayerViewModel footballPlayerVm = new FootballPlayerViewModel();

            ViewBag.Locations             = _adminService.GetLocations(LocationType.Country);
            footballPlayerVm.PreviousLink = this.Url.Action("FootballPlayers", "Admin", this.Request.Url.Scheme);

            return(View(footballPlayerVm));
        }
Ejemplo n.º 3
0
        public int AddFootballPlayer(FootballPlayerViewModel model)
        {
            FootballPlayer player = AutoMapper.Mapper.Map <FootballPlayer>(model);

            UnitOfWork.FootballPlayers.Add(player);
            UnitOfWork.SaveChanges();

            return(player.Id);
        }
Ejemplo n.º 4
0
        public ActionResult EditFootballPlayer([Bind(Include = "Id, FirstName, SecondName, LastName, DateOfBirth, LocationName, PlayerImageUrl")] FootballPlayerViewModel model)
        {
            if (!ModelState.IsValid)
            {
                ViewBag.Locations  = _adminService.GetLocations(LocationType.Country);
                model.PreviousLink = this.Url.Action("FootballPlayers", "Admin", this.Request.Url.Scheme);

                return(View(model));
            }

            _adminService.UpdateFootballPlayer(model);

            return(EditFootballPlayer(model.Id));
        }
Ejemplo n.º 5
0
        public ActionResult AddFootballPlayer(FootballPlayerViewModel model)
        {
            if (!ModelState.IsValid)
            {
                ViewBag.Locations  = _adminService.GetLocations(LocationType.Country);
                model.PreviousLink = this.Url.Action("FootballPlayers", "Admin", this.Request.Url.Scheme);

                return(View(model));
            }

            int playerId = _adminService.AddFootballPlayer(model);

            return(RedirectToAction("EditFootballPlayer", new { footballPlayerId = playerId }));
        }
Ejemplo n.º 6
0
        public void UpdateFootballPlayer(FootballPlayerViewModel model)
        {
            FootballPlayer player = UnitOfWork.FootballPlayers.FirstOrDefault(x => x.Id == model.Id);

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

            player.FirstName      = model.FirstName;
            player.SecondName     = model.SecondName;
            player.LastName       = model.LastName;
            player.NationalityId  = model.NationalityId;
            player.DateOfBirth    = model.DateOfBirth;
            player.PlayerImageUrl = model.PlayerImageUrl;
            player.CDate          = DateTime.Now;

            UnitOfWork.SaveChanges();
        }
        public void SetFootballPlayerToViewModel_WhenOnGetFootballPlayerByIdIsRaised()
        {
            var viewMock            = new Mock <IFootballPlayerView>();
            var footballServiceMock = new Mock <IFootballPlayerService>();

            FootballPlayer footballPlayer = new FootballPlayer();

            footballServiceMock.Setup(x => x.GetFootballPlayerById(It.IsAny <int>())).Returns(footballPlayer);

            FootballPlayerViewModel model = new FootballPlayerViewModel();

            viewMock.Setup(x => x.Model).Returns(model);

            FootballPlayerPresenter presenter = new FootballPlayerPresenter(viewMock.Object, footballServiceMock.Object);

            viewMock.Raise(x => x.OnGetFootballPlayerById += null, new IdEventArgs(8));

            Assert.AreEqual(footballPlayer, viewMock.Object.Model.FootballPlayer);
        }
Ejemplo n.º 8
0
        public ActionResult DeleteFootballPlayer([Bind(Include = "Id")] FootballPlayerViewModel model)
        {
            _adminService.DeleteFootballPlayer(model.Id);

            return(RedirectToAction("FootballPlayers"));
        }