public ActionResult DeleteFootballTeam(int footballTeamId) { FootballTeamViewModel vm = _adminService.GetFootballTeamViewById(footballTeamId); vm.PreviousLink = this.Url.Action("FootballTeams", "Admin", this.Request.Url.Scheme); return(View(vm)); }
public int AddFootballTeam(FootballTeamViewModel model) { FootballTeam footballTeam = AutoMapper.Mapper.Map <FootballTeam>(model); UnitOfWork.FootballTeams.Add(footballTeam); UnitOfWork.SaveChanges(); return(footballTeam.Id); }
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)); }
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 })); }
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)); }
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(); }
public ActionResult DeleteFootballTeam([Bind(Include = "Id, Name, EmblemImageUrl, IsActive")] FootballTeamViewModel model) { _adminService.DeleteFootballTeam(model.Id); return(RedirectToAction("FootballTeams")); }