Example #1
0
        public ActionResult WorkerEdit(Worker worker, int[] selectedProjects)
        {
            Worker newPlayer = db.Workers.Find(worker.Id);

            newPlayer.Name       = worker.Name;
            newPlayer.Surname    = worker.Surname;
            newPlayer.Patronymic = worker.Patronymic;
            newPlayer.Email      = worker.Email;

            if (ModelState.IsValid)
            {
                newPlayer.Projects.Clear();
                if (selectedProjects != null)
                {
                    foreach (var c in db.Projects.Where(co => selectedProjects.Contains(co.Id)))
                    {
                        newPlayer.Projects.Add(c);
                    }
                }

                db.Entry(newPlayer).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("../Home/Index"));
            }
            ViewBag.Projects = db.Projects.ToList();
            return(View(worker));
        }
Example #2
0
        public ActionResult PrjEdit(Project project, int[] selectedWorkers)
        {
            Project newProject = db.Projects.Find(project.Id);

            newProject.Name      = project.Name;
            newProject.Leader    = project.Leader;
            newProject.Customer  = project.Customer;
            newProject.Performer = project.Performer;
            newProject.Priority  = project.Priority;
            newProject.DateStart = project.DateStart;
            newProject.DateEnd   = project.DateEnd;

            if (ModelState.IsValid)
            {
                newProject.Workers.Clear();
                if (selectedWorkers != null)
                {
                    foreach (var c in db.Workers.Where(co => selectedWorkers.Contains(co.Id)))
                    {
                        newProject.Workers.Add(c);
                    }
                }

                db.Entry(newProject).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("../Home/Index"));
            }
            ViewBag.Workers = db.Workers.ToList();
            return(View(project));
        }
        public async Task <Players> Update(Players player)
        {
            _teamContext.Entry(player).State = EntityState.Modified;
            await _teamContext.SaveChangesAsync();

            return(player);
        }
        public async Task <Teams> Update(Teams team)
        {
            _teamContext.Entry(team).State = EntityState.Modified;
            await _teamContext.SaveChangesAsync();

            return(team);
        }
Example #5
0
        public async Task <IActionResult> PutTeam(long id, Team team)
        {
            if (id != team.Id)
            {
                return(BadRequest());
            }

            _context.Entry(team).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!TeamExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Example #6
0
 public ActionResult Edit([Bind(Include = "ID,Name,Wins,Losses,Ties")] Team team)
 {
     if (ModelState.IsValid)
     {
         db.Entry(team).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(team));
 }
Example #7
0
 public ActionResult Edit([Bind(Include = "ID,FirstName,LastName")] Player player)
 {
     if (ModelState.IsValid)
     {
         db.Entry(player).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(player));
 }
Example #8
0
 public ActionResult Edit([Bind(Include = "ID,PlayerName,Position,TeamId")] Player player)
 {
     if (ModelState.IsValid)
     {
         db.Entry(player).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.TeamId = new SelectList(db.Teams, "ID", "SchoolName", player.TeamId);
     return(View(player));
 }
Example #9
0
 public ActionResult Edit(Team model)
 {
     if (ModelState.IsValid)
     {
         db.Entry(model).State = EntityState.Modified;
         db.SaveChanges();
         Session["notification"] = $"{model.Name} was successfully updated!";
         return(RedirectToAction("Index", new { id = 1 }));
     }
     return(View(model));
 }
        public async Task <IActionResult> PutTeam(long id, Team team)
        {
            if (id != team.Id)
            {
                return(BadRequest());
            }

            _context.Entry(team).State = EntityState.Modified;
            await _context.SaveChangesAsync();

            return(NoContent());
        }
Example #11
0
 public ActionResult Edit([Bind(Include = "ID,Name,Wins,Losses,Ties")] Team team)
 {
     if (ModelState.IsValid)
     {
         db.Entry(team).State = EntityState.Modified;
         db.SaveChanges();
         // When a team is edited, the cache is out of date.
         // Clear the cached teams.
         ClearCachedTeams();
         return(RedirectToAction("Index"));
     }
     return(View(team));
 }
Example #12
0
 /// <summary>
 /// The method removes the current users points from their teamID
 /// </summary>
 /// <example>
 /// <code>
 ///  RemovePointsFromOldTeam();
 /// </code>
 /// </example>
 private static void RemovePointsFromOldTeam()
 {
     if (CurrentUser.teamId != 1)
     {
         using (var dbcontext = new TeamContext())
         {
             var oldTeam = dbcontext.Teams.Find(CurrentUser.teamId);
             var oldTeamUpdatedpoints = oldTeam;
             oldTeamUpdatedpoints.TeamPointAmount -= CurrentUser.poitAmount;
             dbcontext.Entry(oldTeam).CurrentValues.SetValues(oldTeamUpdatedpoints);
             // dbcontext.Teams.Add(newTeam);
             dbcontext.SaveChanges();
         }
     }
 }
 public JsonResult UpdatePlayer([FromBody] Player player)
 {
     _teamContext.Entry(player).State = System.Data.Entity.EntityState.Modified;
     _teamContext.SaveChanges();
     return(Json(new { status = "Player updated successfully" }));
 }
Example #14
0
 public void Update(T obj)
 {
     table.Attach(obj);
     _context.Entry(obj).State = EntityState.Modified;
 }
 public string Put(int id,[FromBody] Player player)
 {
     _teamContext.Entry(player).State = System.Data.Entity.EntityState.Modified;
     _teamContext.SaveChanges();
     return "Player updated successfully";
 }