public ActionResult Registar(UserDto dto) { if (ModelState.IsValid) { _userService.AddUser(dto); return RedirectToAction("Index", "Home"); } return View(dto); }
public void AddUser(UserDto dto) { var user = new User() { Username = dto.Username, Password = dto.Password }; _userRepository.Add(user); _userRepository.Save(); }
public ActionResult Login(UserDto dto) { var result = _userService.Login(dto.Username, dto.Password); if (result) { Session["User"] = new User() { Username = dto.Username, Id = dto.Id }; return RedirectToAction("Index", "Home"); } return View(dto); }