public ActionResult Edit(int id, TeamEdit model) { var service = CreateTeamService(); ViewBag.LeagueId = new SelectList(service.GetOwnedList("League"), "LeagueId", "LeagueName"); ViewBag.TeamId = new SelectList(service.GetOwnedList("Team"), "TeamId", "TeamName"); if (!ModelState.IsValid) { return(View(model)); } if (model.TeamId != id) { ModelState.AddModelError("", "Ids are mismatched."); return(View(model)); } if (service.UpdateTeam(model)) { TempData["SaveResult"] = "Team was updated."; return(RedirectToAction("Index")); } ModelState.AddModelError("", "Team could not be updated."); return(View(model)); }
public ActionResult Edit(int id, TeamEdit model) { if (!ModelState.IsValid) { return(View(model)); } if (model.TeamId != id) { ModelState.AddModelError("", "Id Mismatch"); return(View(model)); } var service = CreateTeamService(); if (service.UpdateTeam(model)) { TempData["SaveResult"] = "Your team was updated."; return(RedirectToAction("Index")); } ModelState.AddModelError("", "Your team could not be updated."); return(View(model)); }
// GET: Team/Edit/5 /*[ProjectManagerRequired]*/ public ActionResult Edit(int id) { TeamService r = new TeamService(); CD.Team t = r.Get(id); TeamEdit te = new TeamEdit(t); return(View(te)); }
public ActionResult Edit(int id, TeamEdit collection) { TeamService r = new TeamService(); // Procure les methodes d'acces à la DB CD.Team t = new CD.Team(id, collection.Name); // Création d'une nouvelle équipe à partir du formulaire (collection) if (r.Update(t)) // r.update(): appel de la methide update pour mettre à jour la team, le if(conntrolle si la mise à jour a été faite) { return(RedirectToAction("Details", new { controller = "Team", id = id })); // nous redirige vers l'action detail, se trouvant dans le controller Team avec le parametre Id } return(View(collection)); //retourne le formulaire }
public IHttpActionResult Put(TeamEdit team) { if (!ModelState.IsValid) return BadRequest(ModelState); var service = CreateTeamService(); if (!service.UpdateTeam(team)) return InternalServerError(); return Ok(); }
public bool UpdateTeam(TeamEdit model) { using (var ctx = new ApplicationDbContext()) { var entity = ctx .Teams .Single(e => e.TeamId == model.TeamId); entity.TeamName = model.TeamName; return(ctx.SaveChanges() == 1); } }
//public ActionResult TeamDetails(int id) //{ // var svc = CreateTeamService(); // var model = svc.PlayersOnTeam(id); // return View(model); //} public ActionResult Edit(int id) { var service = CreateTeamService(); var detail = service.GetTeamById(id); var model = new TeamEdit { TeamId = detail.TeamId, Name = detail.Name }; return(View(model)); }
//update team public bool PutTeam(TeamEdit newTeamData) { using (var ctx = new ApplicationDbContext()) { var oldPlayerData = ctx .Teams .Single(p => p.Id == newTeamData.Id); oldPlayerData.Id = newTeamData.Id; oldPlayerData.TeamName = newTeamData.TeamName; return(ctx.SaveChanges() == 1); } }
public ActionResult Edit(int id) { var svc = CreateTeamService(); var detail = svc.GetTeamByID(id); var model = new TeamEdit { TeamID = detail.TeamID, Title = detail.Title, Description = detail.Description }; return(View(model)); }
public ActionResult Edit(int id) { var service = CreateTeamService(); var detail = service.GetTeamByID(id); var model = new TeamEdit { TeamID = detail.TeamID, TeamName = detail.TeamName, VenueName = detail.VenueName }; return(View(model)); }
public bool UpdateTeam(TeamEdit model) { using (var ctx = new ApplicationDbContext()) { var entity = ctx .Team .Single(e => e.TeamID == model.TeamID && e.UserID == model.UserID); entity.TeamName = model.TeamName; //entity.Roster = model.Roster; //entity.TeamEvents = model.TeamEvents; return(ctx.SaveChanges() == 1); } }
public bool UpdateTeam(TeamEdit team) { using (var db = new ApplicationDbContext()) { var entity = db .Teams .Single(e => e.TeamID == team.TeamID && e.CoachID == _userID); entity.TeamName = team.TeamName; entity.TeamDivision = team.TeamDivision; return(db.SaveChanges() == 1); } }
//GET: Team/Edit/id public ActionResult Edit(int id) { var svc = CreateTeamService(); var detail = svc.GetTeamById(id); var model = new TeamEdit { Id = detail.Id, Name = detail.Name, Familiar = detail.Familiar, Assigned = detail.Assigned, }; return(View(model)); }
public bool UpdateTeam(TeamEdit model) { using (var ctx = new ApplicationDbContext()) { var entity = ctx .Teams .Single(e => e.TeamID == model.TeamID && e.OwnerID == _userID); entity.Title = model.Title; entity.Description = model.Description; return(ctx.SaveChanges() == 1); } }
public bool UpdateTeam(TeamEdit model) { using (var ctx = new ApplicationDbContext()) { var entity = ctx .Teams .Single(e => e.TeamId == model.TeamId); entity.Location = model.Location; entity.Name = model.Name; entity.Conference = ctx.Conferences.Single(c => c.Name == model.Conference); entity.TeamId = model.TeamId; return(ctx.SaveChanges() == 1); } }
/// <summary> /// This allows you to update a teams name. /// </summary> /// <param name="team"></param> /// <returns></returns> public IHttpActionResult Put(TeamEdit team) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var teamService = CreateTeamService(); if (teamService.UpdateTeam(team)) { return(InternalServerError()); } return(Ok()); }
public bool UpdateTeam(TeamEdit model) { using (var ctx = new ApplicationDbContext()) { var entity = ctx .TeamDbSet .Single(e => e.TeamId == model.Id); entity.SquadId = model.SquadId; entity.Squad = model.Squad; entity.Name = model.Name; entity.Familiar = model.Familiar; entity.Assigned = model.Assigned; return(ctx.SaveChanges() == 1); } }
public bool UpdateNote(TeamEdit model) { using (var ctx = new ApplicationDbContext()) { var entity = ctx .Teams .Single(e => e.TeamID == model.TeamId && e.OwnerID == _userId); entity.TeamID = model.TeamId; entity.TeamName = model.TeamName; entity.TeamMembers = model.TeamMembers; entity.NumberPeopleTeam = model.NumberPeopleOnTeam; return(ctx.SaveChanges() == 1); } }
public bool UpdateExistingTeam(TeamEdit model) { using (var ctx = new ApplicationDbContext()) { var entity = ctx.Teams.FirstOrDefault(team => team.TeamID == model.TeamID && team.OwnerID == _userID); if (entity == null) { return(false); } entity.TeamName = model.TeamName; entity.LeagueID = model.LeagueID; entity.ImageData = model.ImageData; return(ctx.SaveChanges() == 1); } }
public bool CheckDependencyAccess(TeamEdit model) { using (var ctx = new ApplicationDbContext()) { var ownedTeam = ctx.Teams.FirstOrDefault(team => team.TeamID == model.TeamID && (team.OwnerID == _userID || team.OwnerID == _publicGuid)); if (ownedTeam == null) { return(false); } var ownedLeague = ctx.Leagues.FirstOrDefault(league => league.LeagueID == model.LeagueID && (league.OwnerID == _userID || league.OwnerID == _publicGuid)); if (ownedLeague == null) { return(false); } return(true); } }
public ActionResult Edit(int id, TeamEdit model) { if (!ModelState.IsValid) { return(View(model)); } if (model.Id != id) { ModelState.AddModelError("", "Id Mismatch"); return(View(model)); } var svc = CreateTeamService(); if (svc.UpdateTeam(model)) { TempData["SaveResult"] = "Record updated."; return(RedirectToAction("Index")); } ModelState.AddModelError("", "Unable to update record."); return(View()); }
public IHttpActionResult Put(TeamEdit model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } TeamService service = CreateTeamService(); if (!service.CheckDependencyAccess(model)) { return(BadRequest("Inaccessible dependency")); } if (service.UpdateExistingTeam(model)) { return(Ok()); } return(InternalServerError()); }
public IHttpActionResult Put(int teamId, TeamEdit team) { if (teamId < 1) { return(BadRequest("Invalid Team Entry")); } if (team.TeamId != teamId) { return(BadRequest("Team Number missmatch")); } if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var service = CreateTeamService(); if (!service.UpdateTeam(team)) { return(InternalServerError()); } return(Ok("Team was updated!")); }
public IHttpActionResult PutTeams(int id, TeamEdit team) { if (id < 1) { return(BadRequest("Invalid Team Number entry")); } if (team.Id != id) { return(BadRequest("Team Number missmatch")); } if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var service = CreateTeamService(); var isSuccessful = service.PutTeam(team); if (!isSuccessful) { return(InternalServerError()); } return(Ok("Update Successful!")); }
public ActionResult Edit(int id) { var service = CreateTeamService(); var detail = service.GetTeamById(id); var model = new TeamEdit { TeamId = detail.TeamId, TeamName = detail.TeamName, }; var newLeagueList = new SelectList(service.GetOwnedList("League"), "LeagueId", "LeagueName").ToList(); var sortedLeagueList = newLeagueList.OrderBy(o => o.Text); var newTeamList = new SelectList(service.GetOwnedList("Team"), "TeamId", "TeamName").ToList(); var sortedTeamList = newTeamList.OrderBy(o => o.Text); ViewBag.LeagueId = sortedLeagueList; ViewBag.TeamId = sortedTeamList; ViewBag.LeagueInfo = detail.LeagueName; return(View(model)); }
public ActionResult Edit(int id, TeamEdit team) { if (!ModelState.IsValid) { return(View(team)); } if (team.TeamID != id) { ModelState.AddModelError("", "ID Mismatch"); return(View(team)); } var service = CreateTeamService(); if (service.UpdateTeam(team)) { TempData["SaveResult"] = "Team was updated."; return(RedirectToAction("Index")); } ModelState.AddModelError("", "Team info could not be updated."); return(View(team)); }
public bool UpdateTeam(TeamEdit model) { return(ReturnValue); }