public async Task <BaseInfoResponse> GetBasicUserInformation(int userId, string userName) { BaseInfoResponse response = null; int otherUser; var isUserId = int.TryParse(userName, out otherUser); var result = await Task.Factory.StartNew(() => Context.UserLogins.FirstOrDefault(x => isUserId ? x.UserId == otherUser : x.UserName == userName)).ConfigureAwait(false); if (result != null) { response = new BaseInfoResponse { UserId = result.UserInfo.UserID, UserName = result.UserInfo.UserLogin.UserName, UserTypeId = (SystemUserType)result.UserInfo.UserTypeID, Picture = result.UserInfo.Picture //FriendShipStatus = (SystemFriendshipStatus)await Task.Factory.StartNew(() => Context.FNGETFRIENDSHIPSTATUS(userId, result.UserId).FirstOrDefault().GetValueOrDefault()).ConfigureAwait(false) }; if (result.UserInfo.UserTypeID == (byte)SystemUserType.Person) { var userInfoPerson = result.UserInfo.UserInfoPerson; response.FirstName = userInfoPerson.FirstName; response.LastName = userInfoPerson.LastName; } else { var userInfoCompany = result.UserInfo.UserInfoCompany; response.FirstName = userInfoCompany.Name; } } return(response); }
// SingleData<GeneralKvPair<long, int>> request //public async Task<StatusData<string>> ResetPassword(string resetPasswordCode, string newpassword) //{ // var response = new StatusData<string> { Status = SystemDbStatus.Updated }; // var user = await Task.Factory.StartNew(() => Client.UserService.resetPassword(resetPasswordCode, newpassword)).ConfigureAwait(false); // if (user == null) // { // response.Status = SystemDbStatus.NotFound; // return response; // } // response.Status = (SystemDbStatus)user.DbStatusCode; // response.Message = user.DbStatusMsg; // return response; //} public async Task <StatusData <BaseInfoResponse> > ResetPassword(ResetPasswordRequest request) { var response = new StatusData <BaseInfoResponse> { Status = SystemDbStatus.NotFound }; var user = await Task.Factory.StartNew(() => Client.UserService.resetPassword(request.RequestCode, request.Password)).ConfigureAwait(false); if (user == null) { return(response); } response.Status = (SystemDbStatus)user.DbStatusCode; response.Message = user.DbStatusMsg; if (response.Status.IsOperationSuccessful()) { var result = await Task.Factory.StartNew(() => Client.UserService.getUserInfo(request.UserName, null)).ConfigureAwait(false); if (result.UserId > 0) { var uInfo = new BaseInfoResponse { UserId = Convert.ToInt32(result.UserId), UserName = result.UserName, UserTypeId = (SystemUserType)result.UserTypeId, Picture = result.Picture, Title = result.Title, Email = result.Email, FirstName = result.FirstName, LastName = result.LastName }; response.Data = uInfo; } } return(response); }