public UserApp GetAndUpdateUserAppFromRequest(UpdateUserRequest request) { UserApp user = _userModelServices.findByUserAppId(request.keyUser); user.userName = request.name; user.userEmail = request.emailUser; user.userLastname = request.lastname; user.userNicname = request.nickname; /* * En caso de no tener un número de documento de identificación * el sistema le asigna el número de consumidor final; */ if (string.IsNullOrEmpty(request.numDocument)) { user.userNumDocument = "9999999999"; } else { user.userNumDocument = request.numDocument; } user.userPhone = request.phone; user.userType = request.type; user.CreateAt = DateTime.Now; user.ModifiedAt = DateTime.Now; return(_userModelServices.update(user)); }
public string TryUpdate(UpdateCredentialsRequest request) { string msgValidation = null; var context = _context; var query = from user in context.Set <UserApp>() .Where(u => u.userNicname == request.nickname) select user; if (query.Count() > 0) { UserApp userFound = query.Single(); Boolean isValidPassword = PasswordServices.PasswordMatch(request.currentPass, userFound.userPassword); if (!isValidPassword) { _logger.LogError("[USER NOT MATCH CREDENCIALS] nickname: " + request.nickname); msgValidation = "Nombre de Usuario o Contraseña incorrecta."; } else if (!request.newPass.Equals(request.confirmNewPass)) { _logger.LogError("[NOT MATCH NEW PASSWORD WITH CONFIRMATION] nickname: " + request.nickname); msgValidation = "La contraseña nueva no coincide con la ingresada posteriormente."; } else { userFound.userPassword = PasswordServices.PasswordEncoder(request.newPass); userFound = _userModelServices.update(userFound); /*Actualización del Usuario a estado Activo*/ States stateActive = _statesModelServices.findByKeyword("S001"); StatesOfUser statesOfUser = _statesOfUserModelServices.findByUserAppId(userFound.UserAppId); if (statesOfUser != null) { statesOfUser.ModifiedAt = DateTime.Now; statesOfUser.StatesId = stateActive.StatesId; statesOfUser = _statesOfUserModelServices.update(statesOfUser); } else { msgValidation = "El usuario no tiene asignado un Estado. Contáctese con soporte"; } } } else { _logger.LogError("[USER NOT FOUND] nickname: " + request.nickname); msgValidation = "Nombre de Usuario o Contraseña incorrecta."; } return(msgValidation); }