public async Task <IActionResult> UserInformation()
        {
            if (!SessionUserId.HasValue)
            {
                return(RedirectToAction("SignIn"));
            }

            UserVMO userById = await userService.GetUserById(SessionUserId.Value);

            return(View(userById));
        }
        public async Task <int> GetUserIdByUsername(string username)
        {
            String  userToken          = GetToken();
            UserDTO user               = new UserDTO();
            ApiResponse <UserDTO> data = await request.CallApiWithAuth <ApiResponse <UserDTO> >(ApiGetUserByUsername + username, userToken);

            user = data.Data;
            UserVMO userVMO = VMUserMapper.MapToModel(user);

            return(userVMO.Id);
        }
Beispiel #3
0
        public static UserVMO MapToModel(UserDTO userDto)
        {
            UserVMO user = new UserVMO();

            user.Id       = userDto.Id;
            user.Name     = userDto.Name;
            user.Surname  = userDto.Surname;
            user.Email    = userDto.Email;
            user.Username = userDto.Username;
            return(user);
        }
Beispiel #4
0
        public static UserDTO MapToDTO(UserVMO userVmo)
        {
            UserDTO userDto = new UserDTO();

            userDto.Id       = userVmo.Id;
            userDto.Name     = userVmo.Name;
            userDto.Surname  = userVmo.Surname;
            userDto.Email    = userVmo.Email;
            userDto.Username = userVmo.Username;
            userDto.Password = userVmo.Password;
            return(userDto);
        }
        public async Task <String> SignUp(UserVMO userVmo)
        {
            UserDTO userDto = VMUserMapper.MapToDTO(userVmo);
            ApiResponse <UserDTO> response = await request.AddUser <ApiResponse <UserDTO> >(userDto);

            String result = response.ErrorMessage;

            if (result != null)
            {
                return(result);
            }
            return("OK");
        }
        public async Task <IActionResult> SignUp(UserVMO userVMO)
        {
            ViewData["userData"] = userVMO;

            try
            {
                if (SessionUserId.HasValue)
                {
                    return(RedirectToAction("Home", "Home"));
                }
                else
                {
                    bool passwordOk = userService.ValidatePassword(userVMO.Password);
                    bool emailOk    = userService.ValidateEmail(userVMO.Email);

                    string errorMessage = null;
                    if (passwordOk && emailOk)
                    {
                        String result = await userService.SignUp(userVMO);

                        if (result == "OK")
                        {
                            return(RedirectToAction("SignIn"));
                        }
                        errorMessage = result;
                    }

                    ViewBag.Error = errorMessage ?? "La contraseña o el email no cumplen los requisitos";
                    return(View());
                }
            }
            catch (Exception ex)
            {
                ViewBag.Error = ex.Message;
                return(View());
            }
        }