public async Task <IActionResult> Edit(int id, [Bind("ProfessionId,ProfessionName")] Profession profession)
        {
            if (id != profession.ProfessionId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(profession);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ProfessionExists(profession.ProfessionId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(profession));
        }
        public async Task <IActionResult> Edit(int id, [Bind("InventarId,InventarName,Count,TeamId")] Inventar inventar)
        {
            if (id != inventar.InventarId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(inventar);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!InventarExists(inventar.InventarId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["TeamId"] = new SelectList(_context.Team, "TeamId", "NameTeam", inventar.TeamId);
            return(View(inventar));
        }
예제 #3
0
        public async Task <IActionResult> Edit(int id, [Bind("ContractId,Salary,EndTime,ConclusionTime,StartTime,InForseContract")] Contract contract)
        {
            if (id != contract.ContractId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(contract);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ContractExists(contract.ContractId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(contract));
        }
예제 #4
0
        public async Task <IActionResult> Edit(int id, [Bind("TeamId,NameTeam")] Team team)
        {
            if (id != team.TeamId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(team);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!TeamExists(team.TeamId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(team));
        }
예제 #5
0
        public async Task <IActionResult> Edit(int id, [Bind("PlayerId,Name,DateOfBirhday,RoleOnTheField,Number,Address,PhoneNumber,TransferPrise,Citizenship,Growth,Weight,TeamId,InForceContract,ContractId")] Player player)
        {
            if (id != player.PlayerId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(player);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PlayerExists(player.PlayerId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ContractId"] = new SelectList(_context.Contract, "ContractId", "ContractId", player.ContractId);
            ViewData["TeamId"]     = new SelectList(_context.Team, "TeamId", "NameTeam", player.TeamId);
            return(View(player));
        }
예제 #6
0
        public async Task <IActionResult> Edit(int id, [Bind("PersonalId,Name,DataOfBirthday,PhoneNumber,Address,ProfessionId,ContractId,Professions")] Personal personal)
        {
            if (id != personal.PersonalId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    var professions = personal.Professions.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);

                    var teamsToRemove = _context.PersonalProfession.Where(t => t.PersonalId == personal.PersonalId).ToList();

                    foreach (var tToRemove in teamsToRemove)
                    {
                        _context.PersonalProfession.Remove(tToRemove);
                    }

                    _context.SaveChanges();


                    foreach (var t in professions)
                    {
                        var professionDb = _context.Profession.FirstOrDefault(s => s.ProfessionName == t);
                        if (professionDb != null)
                        {
                            _context.Add(new PersonalProfession {
                                Profession = professionDb, Personal = personal
                            });
                        }
                    }

                    _context.Update(personal);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PersonalExists(personal.PersonalId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ContractId"] = new SelectList(_context.Contract, "ContractId", "ContractId", personal.ContractId);
            return(View(personal));
        }
예제 #7
0
        public async Task <IActionResult> Edit(int id, [Bind("CoachId,Name,DateOfBirhday,Address,PhoneNumber,PositionInTeam,TeamCoach,Teams,ContractId")] Coach coach)
        {
            if (id != coach.CoachId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    var teams = coach.Teams.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);

                    var teamsToRemove = _context.TeamCoach.Where(t => t.CoachId == coach.CoachId).ToList();

                    foreach (var tToRemove in teamsToRemove)
                    {
                        _context.TeamCoach.Remove(tToRemove);
                    }

                    _context.SaveChanges();


                    foreach (var t in teams)
                    {
                        var teamDb = _context.Team.FirstOrDefault(s => s.NameTeam == t);
                        if (teamDb != null)
                        {
                            _context.Add(new TeamCoach {
                                Team = teamDb, Coach = coach
                            });
                        }
                    }

                    _context.Update(coach);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CoachExists(coach.CoachId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ContractId"] = new SelectList(_context.Contract, "ContractId", "ContractId", coach.ContractId);
            return(View(coach));
        }