public async Task <IActionResult> Register(RegisterModel model)
        {
            if (ModelState.IsValid)
            {
                Employees user = await repositoryHandler.GetFirstEntityAsync(u => u.Email == model.Email);

                if (user == null)
                {
                    var employee = new Employees
                    {
                        Email     = model.Email,
                        Password  = model.Password,
                        ShortName = model.ShortName,
                        FullName  = model.FullName
                    };

                    repositoryHandler.Create(employee);

                    return(RedirectToAction("Login"));
                }
                else
                {
                    ModelState.AddModelError("", "Некорректные логин и(или) пароль");
                }
            }
            return(View(model));
        }
Exemplo n.º 2
0
 public IActionResult Add(TaskAddModelHybrid model)
 {
     if (ModelState.IsValid)
     {
         var task = mapper.Map <QTask>(model);
         repositoryHandler.Create(task);
     }
     return(RedirectToAction("Index"));
 }
        public async Task <IActionResult> Add(StaffAddModelHybrid model, [FromServices] IRepositoryHandler <Role> repoRole)
        {
            if (ModelState.IsValid)
            {
                var employee = mapper.Map <Employees>(model);
                employee.Role = await repoRole.GetFirstEntityAsync(r => r.Name == (EmployeeRole)model.Role);

                repositoryHandler.Create(employee);
            }
            return(RedirectToAction("Index"));
        }