예제 #1
0
        public async Task <IActionResult> Create([Bind("ContractId,Salary,EndTime,ConclusionTime,StartTime,InForseContract")] Contract contract)
        {
            if (ModelState.IsValid)
            {
                _context.Add(contract);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(contract));
        }
        public async Task <IActionResult> Create([Bind("ProfessionId,ProfessionName")] Profession profession)
        {
            if (ModelState.IsValid)
            {
                _context.Add(profession);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(profession));
        }
예제 #3
0
        public async Task <IActionResult> Create([Bind("TeamId,NameTeam")] Team team)
        {
            if (ModelState.IsValid)
            {
                _context.Add(team);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(team));
        }
        public async Task <IActionResult> Create([Bind("InventarId,InventarName,Count,TeamId")] Inventar inventar)
        {
            if (ModelState.IsValid)
            {
                _context.Add(inventar);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["TeamId"] = new SelectList(_context.Team, "TeamId", "NameTeam", inventar.TeamId);
            return(View(inventar));
        }
예제 #5
0
        public async Task <IActionResult> Create([Bind("PlayerId,Name,DateOfBirhday,RoleOnTheField,Number,Address,PhoneNumber,TransferPrise,Citizenship,Growth,Weight,TeamId,InForceContract,ContractId")] Player player)
        {
            if (ModelState.IsValid)
            {
                _context.Add(player);
                await _context.SaveChangesAsync();

                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> Register(RegisterModel model)
        {
            if (ModelState.IsValid)
            {
                User user = await _context.User.FirstOrDefaultAsync(u => u.Email == model.Email);

                if (user == null)
                {
                    // добавляем пользователя в бд
                    user = new User {
                        Email = model.Email, Password = model.Password
                    };
                    Role userRole = await _context.Role.FirstOrDefaultAsync(r => r.Name == "user");

                    if (userRole != null)
                    {
                        user.Role = userRole;
                    }

                    _context.User.Add(user);
                    await _context.SaveChangesAsync();

                    await Authenticate(user); // аутентификация

                    return(RedirectToAction("Index", "Home"));
                }
                else
                {
                    ModelState.AddModelError("", "Некоректні логін і(або) пароль");
                }
            }
            return(View(model));
        }
예제 #7
0
        public async Task <IActionResult> Create([Bind("PersonalId,Name,DataOfBirthday,PhoneNumber,Address,ProfessionId,InForceContract,ContractId,Professions")] Personal personal)
        {
            if (ModelState.IsValid)
            {
                var professions = personal.Professions.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                foreach (var profession in professions)
                {
                    var professionDb = _context.Profession.FirstOrDefault(s => s.ProfessionName == profession);
                    if (professionDb != null)
                    {
                        _context.Add(new PersonalProfession {
                            Profession = professionDb, Personal = personal
                        });
                    }
                }
                _context.Add(personal);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ContractId"] = new SelectList(_context.Contract, "ContractId", "ContractId", personal.ContractId);
            return(View(personal));
        }
예제 #8
0
        public async Task <IActionResult> Create([Bind("CoachId,Name,DateOfBirhday,Address,PhoneNumber,PositionInTeam,Teams,ContractId")] Coach coach)
        {
            if (ModelState.IsValid)
            {
                var teams = coach.Teams.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                foreach (var team in teams)
                {
                    var teamDb = _context.Team.FirstOrDefault(s => s.NameTeam == team);
                    if (teamDb != null)
                    {
                        _context.Add(new TeamCoach {
                            Team = teamDb, Coach = coach
                        });
                    }
                }

                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ContractId"] = new SelectList(_context.Contract, "ContractId", "ContractId", coach.ContractId);
            return(View(coach));
        }