Exemplo n.º 1
0
 public ActionResult Edit([Bind(Include = "TeamID,Name,Owner,City,NetWorth")] Team team)
 {
     if (ModelState.IsValid)
     {
         db.Entry(team).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(team));
 }
Exemplo n.º 2
0
 public ActionResult Edit([Bind(Include = "ID,TeamName,Points")] Team team)
 {
     if (ModelState.IsValid)
     {
         db.Entry(team).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(team));
 }
Exemplo n.º 3
0
        public ActionResult EditCaptain(List <TeamMembers> team)
        {
            //team = db.TeamMembersAll.Where(x => x.IsSelected.ToLower() == "yes" && x.IsCaptain.ToLower() != "yes").ToList();

            if (ModelState.IsValid)
            {
                using (db = new TeamDBContext())
                {
                    foreach (var i in team)
                    {
                        var c = db.TeamMembersAll.Where(a => a.Id.Equals(i.Id)).Where(x => x.IsSelected == true && x.IsCaptain != true).FirstOrDefault();
                        if (c != null)
                        {
                            //c.FirstName = i.FirstName;
                            //c.LastName = i.LastName;
                            //c.TotalMatchesPlayed = i.TotalMatchesPlayed;
                            //c.DOB = i.DOB;
                            //c.Email = i.Email;
                            //c.ContactNo = i.ContactNo;
                            //c.Height = i.Height;
                            //c.Weight = i.Weight;
                            //c.Role = i.Role;

                            //c.IsSelected = i.IsSelected;
                            c.IsPlaying = i.IsPlaying;
                            //c.IsCaptain = i.IsCaptain;
                        }
                        db.Entry(c).State = EntityState.Modified;
                    }

                    db.SaveChanges();
                }
                ViewBag.Message = "Successfully Updated.";
                return(RedirectToAction("CaptainIndex"));
            }
            else
            {
                ViewBag.Message = "Failed ! Please try again.";
                return(View(team));
            }
        }