Ejemplo n.º 1
0
        public ActionResult Registration(DtoUser dtoUser)
        {
            if (!ModelState.IsValid) return View(dtoUser);

            Mapper.CreateMap<DtoUser, User>();
            User user = Mapper.Map<User>(dtoUser);
            var isRegistered = user.Register(_userRepository);

            if (isRegistered)
                return RedirectToAction("Index", "Home");

            ModelState.AddModelError("WrongModel", Config.LoginAlreadyInUseMessage);
            return View(dtoUser);
        }
Ejemplo n.º 2
0
        public ActionResult Login(DtoUser dtoUser)
        {
            if (ModelState.IsValid)
            {
                Mapper.CreateMap<DtoUser, User>();
                User user = Mapper.Map<User>(dtoUser);
                var isLogin = user.Login(_userRepository);

                if (isLogin)
                {
                    return RedirectToAction("Index", "Home");
                }
            }

            ModelState.AddModelError("WrongModel", Config.WrongLoginOrPassMessage);
            return View(dtoUser);
        }