public async Task <IActionResult> Create([Bind("MileStoneId,EmployeeSkillValueId,Date")] MileStone mileStone, string Login) { if (ModelState.IsValid) { _context.Add(mileStone); await _context.SaveChangesAsync(); return(RedirectToAction("Index", "MileStones", new { login = Login })); } ViewData["EmployeeSkillValueId"] = new SelectList(_context.EmployeeSkillValue, "EmployeeSkillValueId", "EmployeeSkillValueId", mileStone.EmployeeSkillValueId); return(View(mileStone)); }
public async Task <IActionResult> Create([Bind("CommentId,AuthorId,MileStoneId,CommentValue")] Comment comment, string Login) { if (ModelState.IsValid) { _context.Add(comment); await _context.SaveChangesAsync(); return(RedirectToAction("Index", "MileStones", new { login = Login })); } ViewData["MileStoneId"] = new SelectList(_context.MileStone, "MileStoneId", "MileStoneId", comment.MileStoneId); return(View(comment)); }
public IActionResult AddExistingIntern(string MentorLogin, int?InternId) { if (MentorLogin == null || InternId == null) { return(NotFound()); } var Mentor = _context.Employee.Include(m => m.EmployeeAccount).Where(m => m.EmployeeAccount.Login == MentorLogin).First(); var Intern = _context.Employee.Find(InternId); if (Mentor == null || Intern == null) { return(NotFound()); } EmployeeMentors employeeMentors = new EmployeeMentors { MentorId = Mentor.EmployeeId, InternId = Intern.EmployeeId, }; _context.EmployeeMentors.Add(employeeMentors); _context.SaveChangesAsync(); return(RedirectToAction("Info", new { login = Mentor.EmployeeAccount.Login })); }
public async Task <IActionResult> Register(RegisterModel model) { if (ModelState.IsValid) { EmployeeAccount employeeAccount = await _context.EmployeeAccount.FirstOrDefaultAsync(u => u.Login == model.Login); if (employeeAccount == null) { employeeAccount = new EmployeeAccount { Login = model.Login, Password = model.Password }; _context.EmployeeAccount.Add(employeeAccount); await _context.SaveChangesAsync(); Employee employee = new Employee { EmployeeId = employeeAccount.EmployeeAccountId, Name = model.Name, Surname = model.Surname, Patronymic = model.Patronymic, Email = model.Email, EmployeeRoleId = model.EmployeeRoleId, RankId = model.RankId, PhoneNumber = model.PhoneNumber }; _context.Employee.Add(employee); await _context.SaveChangesAsync(); if (model.MentorId != null) { EmployeeMentors employeeMentors = new EmployeeMentors { MentorId = model.MentorId.Value, InternId = employee.EmployeeId, }; _context.EmployeeMentors.Add(employeeMentors); } foreach (var skillVal in model.SkillsValue) { EmployeeSkillValue employeeSkillValue = new EmployeeSkillValue { EmployeeId = employee.EmployeeId, SkillId = _context.Skill.Where(u => u.SkillTitle == skillVal.Key && u.SkillValueId == skillVal.Value).First().IdSkill }; _context.EmployeeSkillValue.Add(employeeSkillValue); } await _context.SaveChangesAsync(); // await Login(new LoginModel() { Login = model.Login, Password = model.Password}); // аутентификация return(RedirectToAction("Index", "Home")); } ModelState.AddModelError("", "Такий логін вже використано"); } ViewBag.EmployeeRoleId = new SelectList(_context.EmployeeRole, "EmployeeRoleId", "EmployeeRoleName"); ViewBag.RankId = new SelectList(_context.EmployeeRank, "EmployeeRankId", "EmployeeRankTitle"); return(View(model)); }