public ActionResult DeleteFootballPlayer(int footballPlayerId) { FootballPlayerViewModel vm = _adminService.GetFootballPlayerViewById(footballPlayerId); vm.PreviousLink = this.Url.Action("FootballPlayers", "Admin", this.Request.Url.Scheme); return(View(vm)); }
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)); }
public int AddFootballPlayer(FootballPlayerViewModel model) { FootballPlayer player = AutoMapper.Mapper.Map <FootballPlayer>(model); UnitOfWork.FootballPlayers.Add(player); UnitOfWork.SaveChanges(); return(player.Id); }
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)); }
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 })); }
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); }
public ActionResult DeleteFootballPlayer([Bind(Include = "Id")] FootballPlayerViewModel model) { _adminService.DeleteFootballPlayer(model.Id); return(RedirectToAction("FootballPlayers")); }