public IActionResult SaveTeam(int id, [Bind("TeamId,SectionId,Name")] TeamVm viewModel) { TeamVmValidator validator = new TeamVmValidator(); ValidationResult validationResult = validator.Validate(viewModel); if (validationResult.IsValid) { _teamManagement.UpdateTeam(viewModel.Team()); } else { foreach (ValidationFailure failure in validationResult.Errors) { ModelState.AddModelError(failure.PropertyName, failure.ErrorMessage); } } var section = _sectionManagement.GetSectionById(viewModel.SectionId); viewModel.Section = section; viewModel.SectionId = section.SectionId; viewModel.Section.Tournament = _tournamentManagement.GetTournamentById(section.TournamentId); return(View("TeamAdminForm", viewModel)); }
// GET: Teams/SaveTeam/5 public IActionResult SaveTeam(int sectionId) { TeamVm viewModel = new TeamVm(); var section = _sectionManagement.GetSectionById(sectionId); viewModel.Section = section; viewModel.SectionId = section.SectionId; viewModel.Section.Tournament = _tournamentManagement.GetTournamentById(section.TournamentId); return(View("TeamAdminForm", viewModel)); }
private Team Parse(TeamVm item) { Team details = new Models.Team { FacebookUrl = item.FacebookUrl, GooglePlusUrl = item.GooglePlusUrl, img = item.img, Name = item.Name, TwitterUrl = item.TwitterUrl, TeamId = item.TeamId }; return(details); }
public ActionResult Edit(TeamVm obj) { try { obj.Team.Published = obj.IsPublish; obj.Team.Deleted = obj.IsDelete; _repository.Edit(obj.Team); return(RedirectToAction("Index")); } catch (Exception ex) { return(View(ex.Message)); } }
public ActionResult Create(TeamVm team) { ModelState.Remove("Img"); if (ModelState.IsValid) { team.img = team.imgAttach.FileName; _context.Teams.Add(Parse(team)); _context.SaveChanges(); // upload image team.imgAttach.SaveAs(Server.MapPath("~/images/teams/" + team.img)); return(View()); } return(View()); }
public ActionResult Create(TeamVm obj) { try { obj.Team.LanguageId = 1; // language vietnamese obj.Team.CreatedOn = DateTime.Now; obj.Team.Deleted = false; obj.Team.Published = obj.IsPublish; obj.Team.Deleted = obj.IsDelete; _repository.Add(obj.Team); return(RedirectToAction("Index")); } catch (Exception ex) { return(View(ex.Message)); } }
// GET: Team public ActionResult Index(string Slug, int AdminId) { if (db.Teams.FirstOrDefault(t => t.Slug == Slug && t.UserId == AdminId) == null || Slug == null || AdminId == 0) { return(HttpNotFound()); } int userId = Convert.ToInt32(Session["UserId"]); TeamVm model = new TeamVm() { Admin = db.Users.FirstOrDefault(u => u.Id == userId), Users = db.Users.ToList(), Team = db.Teams.FirstOrDefault(t => t.Slug == Slug && t.UserId == AdminId), Tasks = db.Tasks.ToList(), TaskStages = db.TaskStages.ToList(), TaskMembers = db.TaskMembers.ToList(), Projects = db.Projects.OrderByDescending(p => p.StartTime).ToList(), ProjectMembers = db.ProjectMembers.ToList() }; model.TeamMembers = db.TeamMembers.Where(m => m.TeamId == model.Team.Id).OrderByDescending(m => m.Id).ToList(); return(View(model)); }
public IActionResult Edit(int id) { if (id == 0) { return(NotFound()); } var team = _teamManagement.GetTeamById(id); if (team == null) { return(NotFound()); } TeamVm viewModel = new TeamVm(team); var section = _sectionManagement.GetSectionById(team.SectionId); viewModel.SectionId = section.SectionId; viewModel.Section = section; viewModel.Section.Tournament = _tournamentManagement.GetTournamentById(section.TournamentId); return(View("TeamAdminForm", viewModel)); }
public TeamController() { _vm = new TeamVm(); _repository = new TeamDao(); }