public async Task <IActionResult> Login(UserAuthDTO model) { if (ModelState.IsValid) { var user = await userServ.GetModel() .Include(u => u.Role) .FirstOrDefaultAsync(u => u.Email == model.Email && u.Password == model.Password); if (user != null) { await Authenticate(user); // аутентификация return(RedirectToAction("Info", "Reports", new { area = "Admin" })); } ModelState.AddModelError("", "Некорректные логин и(или) пароль"); } return(View(model)); }
public async Task <IActionResult> Edit(Guid id, UserDetailDTO model) { if (id != model.Id) { return(NotFound()); } if (id == Guid.Empty) { var user = await userServ.GetModel().FirstOrDefaultAsync(u => u.Email == model.Email); if (user != null) { ModelState.AddModelError("Email", "Користувач з таким Email вже існує"); } } if (ModelState.IsValid) { model.Password = "******"; try { await userServ.SaveAsync(model); } catch (DbUpdateConcurrencyException) { if (await userServ.GetListDTO().SingleOrDefaultAsync(x => x.Id == id) == null) { return(NotFound()); } else { throw; } } return(RedirectToAction("Journal")); } return(View(model)); }