public UserProfileResponse Get(UserProfileRequest request) { UserDocument user = ViewContext.Users.GetById(request.UserId == Me ? TypedSession.UserId : request.UserId); if (user == null) { throw HttpError.NotFound("User with UserId = {0} does not exist".Fmt(request.UserId)); } return new UserProfileResponse { UserId = user.Id, FirstName = user.FirstName, LastName = user.LastName, Rating = user.Reputation, PhotoBigUri = user.PhotoBigUri, PhotoSmallUri = user.PhotoSmallUri, QuestionsCount = ViewContext.Questions.AsQueryable().Count(x => x.AuthorId == user.Id), AnswersCount = ViewContext.Answers.AsQueryable().Count(x => x.AuthorId == user.Id), FbProfile = user.LoginType == UserLoginType.Facebook ? "https://www.facebook.com/" + user.ThirdPartyId : string.Empty, VkProfile = user.LoginType == UserLoginType.Vk ? "http://vk.com/id" + user.ThirdPartyId : string.Empty }; }
public async Task <UserSettingsResponse> CreateUserSettingsAsync(UserProfileRequest request) { Ensure.That(request, nameof(request)).IsNotNull(); var settingsExist = await _store.DoesExistAsync(request.UserId); if (settingsExist) { throw new ConflictException(new ErrorDto(ErrorCode.ConflictError, "User profile already exists.")); } var profile = Mapper.Map <UserProfileRequest, UserSettings>(request); profile.Settings = GetDefaultSettings(); var newProfile = await _store.SaveAsync(profile); return(Mapper.Map <UserSettings, UserSettingsResponse>(newProfile)); }
public async Task <ActionResult> UpdateProfile([FromBody] UserProfileRequest register) { try { _UserProfileResponse = await _userService.UpdateProfile(register); if (_UserProfileResponse.Status == false) { return(new OkObjectResult(_UserProfileResponse)); } return(new OkObjectResult(_UserProfileResponse)); } catch (Exception ex) { _UserProfileResponse.Message = ex.Message; _UserProfileResponse.Status = false; return(BadRequest(_UserProfileResponse)); } }
// // GET: /UserProfile/ public ActionResult Results(UserProfileRequest userProfileRequest) { var context = new SAContext(); var existingProfile = context.UserProfiles.Where( x => x.FirstName == userProfileRequest.UserProfile.FirstName && x.MiddleName == userProfileRequest.UserProfile.MiddleName && x.LastName == userProfileRequest.UserProfile.LastName).SingleOrDefault(); if (existingProfile == null) { context.UserProfiles.Add(userProfileRequest.UserProfile); context.SaveChanges(); } else { userProfileRequest.ErrorMessage = "Error, user profile already exists. Please try again."; return(View("Index", userProfileRequest)); } return(View()); }
public async Task <UserProfileResponse> Delete(UserProfileRequest request) { UserProfileResponse response = new UserProfileResponse(); try { if (await iUserProfile.Delete(request.RoleID)) { return(response); } response.Message = "Failed to Delete UserProfile"; response.IsSuccess = false; } catch (Exception ex) { response.Message = "Opps, Something Error in Our System : " + ex.Message; response.IsSuccess = false; } return(response); }
public async Task <UserProfileResponse> Add(UserProfileRequest request) { UserProfileResponse response = new UserProfileResponse(); try { UserProfile usrProfile = new UserProfile(); if (!(await iUserProfile.IsDuplicate(request.Email))) { usrProfile.Email = request.Email; usrProfile.Password = EncryptString(request.Password); usrProfile.FirstName = request.FirstName; usrProfile.LastName = request.LastName; usrProfile.GenderId = request.Gender; usrProfile.Age = request.Age; usrProfile.RoleId = request.RoleID; usrProfile.Created = DateTime.Now.ToLocalTime(); usrProfile.CreatedBy = request.CurrentLogin; usrProfile.RowStatus = request.RowStatus; if (await iUserProfile.Add <UserProfile>(usrProfile)) { return(response); } response.Message = "Failed to Add UserProfile"; response.IsSuccess = false; } else { response.Message = "Email Is Duplicate with Existing Data"; response.IsSuccess = false; } } catch (Exception ex) { response.Message = "Opps, Something Error in Our System : " + ex.Message; response.IsSuccess = false; } return(response); }
private void listBox1_DoubleClick(object sender, EventArgs e) { if (listBox1.SelectedItem != null) { ChatUser user = listBox1.SelectedItem as ChatUser; if (user != null) { if (user.Stats.Product == Product.Warcraft3Retail || user.Stats.Product == Product.Warcraft3Expansion) { m_client.RequestWarcraft3Profile(user); } else { UserProfileRequest request = new UserProfileRequest(user.Username, UserProfileKey.Age, UserProfileKey.Sex, UserProfileKey.Location, UserProfileKey.Description, UserProfileKey.AccountCreated, UserProfileKey.LastLogon, UserProfileKey.LastLogoff, UserProfileKey.TotalTimeLogged); m_client.RequestUserProfile(user.Username, request); } } } }
public async Task <BaseResponse> UpdateUserRole(UserProfileRequest profileRequest) { BaseResponse baseResponse = new BaseResponse(); try { var updateUserRoles = ObjContext.UserRole.Where(ur => ur.Userld == profileRequest.UserId).ToList(); if (updateUserRoles != null) { for (int i = 0; i <= updateUserRoles.Count - 1; i++) { updateUserRoles[i].IsDeleted = true; updateUserRoles[i].DeletedBy = "Admin"; updateUserRoles[i].DeletedOn = DateTime.Now; await ObjContext.SaveChangesAsync(); } } if (profileRequest.updateUserRoles.Count > 0) { for (int i = 0; i <= profileRequest.updateUserRoles.Count - 1; i++) { UserRole userRole = new UserRole(); userRole.Userld = profileRequest.UserId; userRole.RoleId = profileRequest.updateUserRoles[i].RoleId; userRole.ModifiedBy = "Admin"; userRole.ModifiedOn = DateTime.Now; ObjContext.UserRole.Add(userRole); await ObjContext.SaveChangesAsync(); } } baseResponse.Status = true; } catch (Exception ex) { baseResponse.Status = false; baseResponse.Message = ex.Message; } return(baseResponse); }
public async Task UpdateUserSettingsTest() { var service = new Mock <ISettingsService>(); var request = new UserProfileRequest { Email = "alex@", FirstName = "alex", Language = LanguageName.Fr, LastName = "softeq", PhoneNumber = "123" }; var response = new UserProfileResponse { UserId = UserId, Email = "alex@", FirstName = "alex", Language = LanguageName.Fr, LastName = "softeq", PhoneNumber = "123" }; UserProfileRequest req = null; service.Setup(x => x.UpdateUserSettingsAsync(It.Is <UserProfileRequest>(sr => sr == request && sr.UserId == UserId))) .Callback <UserProfileRequest>(r => req = r) .ReturnsAsync(response) .Verifiable(); var controller = new SettingsController(_logger, service.Object).WithUser(); var result = await controller.UpdateUserSettingsAsync(request); service.Verify(); var res = Assert.IsType <OkObjectResult>(result); Assert.Equal(response, res.Value); Assert.IsType <UserProfileResponse>(res.Value); }
public async Task CreateUserSettingsSuccessfullyTest() { var userId = Guid.NewGuid().ToString(); var request = new UserProfileRequest { Email = "*****@*****.**", FirstName = "Alex", Language = LanguageName.Fr, LastName = "Softeq", PhoneNumber = "123", UserId = userId }; UserSettings newSettings = null; var store = new Mock <ISettingsDataStore>(); store.Setup(x => x.DoesExistAsync(It.Is <string>(s => s == userId))).ReturnsAsync(false); store.Setup(x => x.SaveAsync(It.IsAny <UserSettings>())) .Callback <UserSettings>(settings => newSettings = settings) .ReturnsAsync(() => newSettings); var service = new SettingsService(store.Object, DefaultMapper); var response = await service.CreateUserSettingsAsync(request); store.Verify(x => x.SaveAsync(It.IsAny <UserSettings>()), Times.Once); VerifyUserSettings(request, response); var flatten = NotificationEventConfiguration.Config .SelectMany(f => f.Value.Where(x => !x.IsMandatory).Select(s => (f.Key, s))) .ToList(); Assert.Equal(flatten.Count, response.Settings.Count()); foreach (var setting in flatten) { Assert.NotNull(response.Settings.FirstOrDefault(x => x.Enabled && x.Type == setting.Item1 && x.Event == setting.Item2.Event)); } }
public async Task SuccessfulUserSettingsUpdateTest() { var userId = Guid.NewGuid().ToString(); var currentSettings = new UserSettings { UserId = userId, LastName = "oldLast", FirstName = "oldFirst", Email = "oldEmail", PhoneNumber = "oldPhone", Language = LanguageName.En }; var request = new UserProfileRequest { Email = "*****@*****.**", FirstName = "Alex", Language = LanguageName.Fr, LastName = "Softeq", PhoneNumber = "123", UserId = userId }; UserSettings newSettings = null; var store = new Mock <ISettingsDataStore>(); store.Setup(x => x.FindAsync(It.Is <string>(s => s == userId))).ReturnsAsync(currentSettings); store.Setup(x => x.UpdateAsync(It.IsAny <UserSettings>())) .Callback <UserSettings>(settings => newSettings = settings) .ReturnsAsync(() => newSettings); var service = new SettingsService(store.Object, DefaultMapper); var response = await service.UpdateUserSettingsAsync(request); store.Verify(x => x.UpdateAsync(It.IsAny <UserSettings>()), Times.Once); VerifyUserSettings(request, response); }
public async Task <IActionResult> Add([FromBody] UserProfileRequest request) { try { authHelper.IsLogin(ref CurrentLogin, ref response, HttpContext.User.Identity as ClaimsIdentity); if (response.IsSuccess) { request.CurrentLogin = CurrentLogin; if (request.UserProfileID > 0) { return(Ok(await facade.Update(request))); } else { return(Ok(await facade.Add(request))); } } return(Ok(response)); } catch (Exception ex) { return(BadRequest(ex.Message)); } }
public void Test_UserProfileRequest_Has_AuthorizationRequirement_Optional() { var request = new UserProfileRequest(); request.AuthorizationRequirement.Should().Be(AuthorizationRequirement.Optional); }
/// <summary> /// Sets the userProfiles. /// </summary> /// <param name="request">The request.</param> /// <returns></returns> public UserProfileResponse SetUserProfiles(UserProfileRequest request) { var response = new UserProfileResponse(); var userProfileEntity = request.UserProfile; if (request.Action != PersistType.Delete && userProfileEntity != null) { if (!userProfileEntity.Validate()) { foreach (var error in userProfileEntity.ValidationErrors) { response.Message += error + Environment.NewLine; } response.Acknowledge = AcknowledgeType.Failure; return(response); } } try { if (request.Action == PersistType.Insert) { if (userProfileEntity != null) { userProfileEntity.UserProfileId = UserProfileDao.InsertUserProfile(userProfileEntity); if (userProfileEntity.UserProfileId == 0) { response.Acknowledge = AcknowledgeType.Failure; return(response); } } } else if (request.Action == PersistType.Update) { response.Message = UserProfileDao.UpdateUserProfile(userProfileEntity); if (response.Message != null) { response.Acknowledge = AcknowledgeType.Failure; return(response); } } else if (request.Action == PersistType.Delete) { var userProfileForDelete = UserProfileDao.GetUserProfile(request.UserProfileId); response.Message = UserProfileDao.DeleteUserProfile(userProfileForDelete); if (response.Message != null) { response.Acknowledge = AcknowledgeType.Failure; response.RowsAffected = 0; return(response); } response.RowsAffected = 1; } else { var userProfileForUpdate = UserProfileDao.GetUserProfileByUserProfileName(request.UserProfileName, request.OldPassword); if (userProfileForUpdate == null) { response.Acknowledge = AcknowledgeType.Failure; response.Message = @"Mật khẩu cũ không chính xác !"; return(response); } //assign new password userProfileForUpdate.Password = request.Password; response.Message = UserProfileDao.UpdateUserProfile(userProfileForUpdate); if (response.Message != null) { response.Acknowledge = AcknowledgeType.Failure; return(response); } response.RowsAffected = 1; } } catch (Exception ex) { response.Acknowledge = AcknowledgeType.Failure; response.Message = ex.Message; return(response); } response.UserProfileId = userProfileEntity != null ? userProfileEntity.UserProfileId : 0; return(response); }
public async Task <IActionResult> UpdateProfileAsync([FromBody] UserProfileRequest profileRequest) { return(Ok(await _userProfileService.UpdateProfileAsync(profileRequest))); }
public void TestValidateUsername() { UserProfileRequest loginRequest = new UserProfileRequest { UserName = "******", }; var profileLogic = new ProfileLogic(); CommonResponse response = profileLogic.ValidateLoginUserName(loginRequest); }
/// <summary> /// Creates a new <see>UserProfileEventArgs</see> with the specified profile. /// </summary> /// <param name="filledProfile">The profile that had been populated.</param> public UserProfileEventArgs(UserProfileRequest filledProfile) { Debug.Assert(!object.ReferenceEquals(filledProfile, null)); m_profile = filledProfile; }
/// <summary> /// Requests a user's profile. /// </summary> /// <param name="accountName">The name of the user for whom to request information.</param> /// <param name="profile">The profile request, which should contain the keys to request.</param> public virtual void RequestUserProfile(string accountName, UserProfileRequest profile) { BncsPacket pck = new BncsPacket((byte)BncsPacketId.ReadUserData); pck.InsertInt32(1); pck.InsertInt32(profile.Count); int currentRequest = Interlocked.Increment(ref m_currentProfileRequestID); pck.InsertInt32(currentRequest); pck.InsertCString(accountName); foreach (UserProfileKey key in profile) { pck.InsertCString(key.Key); } m_profileRequests.Add(currentRequest, profile); Send(pck); }
public async Task <UserProfileModel> Profile([FromBody] UserProfileRequest model) { return(await _accountService.UpdateProfile(UserId, model)); }
private void SaveTalentData(UserProfileRequest request, UserInformation user) { Context.EmployeeAvailability.Add(new Data.SotEntities.EmployeeAvailability { Available = request.AvailablityInfo.IsAvailable, EmployeeId = user.Id, Reason = request.AvailablityInfo.Explanation }); Context.SaveChanges(); request.Skills.ForEach(skl => { SkillType skill = new SkillType { Id = new Random().Next(90000000), Name = skl.Name, Description = skl.Description }; Context.SkillType.Add(skill); Context.SaveChanges(); Context.EmployeeSkill.Add(new EmployeeSkill { EmployeeId = user.Id, ExpertiseLvlId = skl.LevelOfExpertise.Id, SkillId = skill.Id }); Context.SaveChanges(); }); Context.EmployeePortfolio.Add(new EmployeePortfolio { EmployeeId = user.Id, Projects = SerializeObjectToJson(request.Portfolio.Projects) }); Context.SaveChanges(); request.EmployementHistory.ForEach(es => { Context.EmploymentHistory.Add(new EmploymentHistory { Description = es.JobDescription, EmployeeId = user.Id, Position = es.Position, StartDate = es.StartDate, EndDate = es.EndDate }); Context.SaveChanges(); }); request.EducationHistory.ForEach(eds => { Context.EducationHistory.Add(new EducationHistory { Description = eds.Description, EndDate = eds.EndDate, StartDate = eds.StartDate, EmployeeId = user.Id, Field = eds.FieldOfStudy }); Context.SaveChanges(); }); }
public UserProfileResponse UpdateProfile([FromBody] UserProfileRequest request) { var userId = User.GetUserId(); return(_userService.Update(userId, request)); }
public void Test_UserProfileRequest_Has_Valid_UriTemplate() { var request = new UserProfileRequest(); request.UriTemplate.Should().Be("users/{username}{?extended}"); }
public async Task <ResponseBase> SaveProfile([FromBody] UserProfileRequest signup) { return(await _userService.SaveUserProfile(signup)); }
public UserProfile() { facade = new UserProfileFacade(connectionString, kunciRahasiaku); request = new UserProfileRequest(); }
public void TestMatch() { MatchLogic matchLogic = new MatchLogic(); var dataManager = new DataManager(); MatchRequest req = new MatchRequest(); var userDataPuddy = new UserProfileRequest { //UserID = 69, UserName = "******", ProfileAttributeType = ProfileAttributeTypeEnum.All }; UserProfileData match = dataManager.FetchProfile(userDataPuddy); // This is elaine. req.UserID = 6969; MatchResponse response = matchLogic.GetMatchByLocation(req); if (response != null) { if (response.MatchProfiles != null && response.MatchProfiles.Count() > 0) { foreach (ChoiceProfile cp in response.MatchProfiles) { cp.ChoiceType = ChoiceTypeEnum.Like; } // Add the match profiles var userProfileData = new UserProfileData { UserData = match.UserData, UserChoices = response.MatchProfiles }; dataManager.ModifyProfile(userProfileData); } } }
private User UpdateUserProfile(User user, UserProfileRequest request) { UpdateUserFields(user, request); Update(user); return(user); }
public void TestUpdateProfileData() { var dataManager = new DataManager(); /* var userData = new UserData { UserID = 34, UserName = "******", FirstName = "David", LastName = "Puddy", Email = "*****@*****.**", DisplayName = "Pud6dy9", PhoneNumber = "3016969696", Password = "******" }; ProfileEntity userResponse = new ProfileEntity { Id = 8, ID = 12, QuestionID = 1 }; ProfileEntity matchResponseUpdate = new ProfileEntity { Id = 11, ID = 13, QuestionID = 2 }; ProfileEntity matchResponseNew = new ProfileEntity { Id = 27, }; List<ProfileEntity> userRespounses = new List<ProfileEntity>(); userRespounses.Add(userResponse); List<ProfileEntity> matchRespounses = new List<ProfileEntity>(); matchRespounses.Add(matchResponseUpdate); matchRespounses.Add(matchResponseNew); var userProfileData = new UserProfileData { UserData = userData, UserResponses = userRespounses, MatchResponses = matchRespounses }; dataManager.ModifyProfile(userProfileData); */ /* if (data.UserData != null) { data.UserData.DisplayName = "Giddy6969"; ProfileEntity userResponse = new ProfileEntity { Id = 17, ResponseTypeID = 2 }; List<ProfileEntity> userRespounses = new List<ProfileEntity>(); userRespounses.Add(userResponse); ProfileEntity matchResponse = new ProfileEntity { Id = 19, ResponseTypeID = 2 }; ProfileEntity matchResponse2 = new ProfileEntity { Id = 20, ResponseTypeID = 2 }; List<ProfileEntity> matchRespounses = new List<ProfileEntity>(); matchRespounses.Add(matchResponse); matchRespounses.Add(matchResponse2); var userProfileData = new UserProfileData { UserData = data.UserData, //UserResponses = userRespounses, MatchResponses = matchRespounses }; dataManager.ModifyProfile(userProfileData); } */ var userDataPuddy = new UserProfileRequest { //UserID = 69, UserName = "******", ProfileAttributeType = ProfileAttributeTypeEnum.All }; UserProfileData match = dataManager.FetchProfile(userDataPuddy); if (match.UserData != null) { //match.UserData.DisplayName = "Giddy6969"; ProfileEntity userResponse = new ProfileEntity { Id = 17, ResponseTypeID = 2 }; ProfileEntity userResponse2 = new ProfileEntity { Id = 12, ResponseTypeID = 1 }; ProfileEntity userResponse3 = new ProfileEntity { Id = 6, ResponseTypeID = 3 }; List<ProfileEntity> userRespounses = new List<ProfileEntity>(); userRespounses.Add(userResponse); userRespounses.Add(userResponse2); userRespounses.Add(userResponse3); ProfileEntity matchResponse = new ProfileEntity { Id = 7, ResponseTypeID = 3 }; ProfileEntity matchResponse2 = new ProfileEntity { Id = 24, ResponseTypeID = 4 }; ProfileEntity matchResponse3 = new ProfileEntity { Id = 10, ResponseTypeID = 1 }; ProfileEntity matchResponse4 = new ProfileEntity { Id = 23, ResponseTypeID = 2 }; List<ProfileEntity> matchRespounses = new List<ProfileEntity>(); matchRespounses.Add(matchResponse); matchRespounses.Add(matchResponse2); matchRespounses.Add(matchResponse3); matchRespounses.Add(matchResponse4); var userProfileData = new UserProfileData { UserData = match.UserData, UserResponses = userRespounses, MatchResponses = matchRespounses }; dataManager.ModifyProfile(userProfileData); } /* ProfileEntity matchResponseNew = new ProfileEntity { Id = 3, }; ChoiceProfile choiceResponse = new ChoiceProfile { ChoiceType = ChoiceTypeEnum.Like, UserID = 34, MatchUser = new UserData { UserID = 12, UserName = "******" } }; List<ChoiceProfile> userChoices = new List<ChoiceProfile>(); userChoices.Add(choiceResponse); var userProfileData = new UserProfileData { UserData = data.UserData, UserChoices = userChoices }; dataManager.ModifyProfile(userProfileData); */ }
private void listBox1_DoubleClick(object sender, EventArgs e) { if (listBox1.SelectedItem != null) { ChatUser user = listBox1.SelectedItem as ChatUser; if (user != null) { if (user.Stats.Product == Product.Warcraft3Retail || user.Stats.Product == Product.Warcraft3Expansion) { m_client.RequestWarcraft3Profile(user); } else { UserProfileRequest request = new UserProfileRequest(user.Username, UserProfileKey.Age, UserProfileKey.Sex, UserProfileKey.Location, UserProfileKey.Description, UserProfileKey.AccountCreated, UserProfileKey.LastLogon, UserProfileKey.LastLogoff, UserProfileKey.TotalTimeLogged); m_client.RequestUserProfile(user.Username, request); } } } }
public UserProfileResponse CreateUserInformation(UserProfileRequest request) { PassContext(_accountService, Context); return(_accountService.CreateUserInformation(request)); }
public override void RequestUserProfile(string accountName, UserProfileRequest profile) { eventsToFire.Enqueue(new InvokeHelper <UserProfileEventArgs> { Target = OnUserProfileReceived, Arguments = new UserProfileEventArgs(profile) }); }
public void TestFetchProfileData() { try { var dataManager = new DataManager(); var userData = new UserProfileRequest { //UserID = 69, UserName = "******", ProfileAttributeType = ProfileAttributeTypeEnum.All }; UserProfileData data = dataManager.FetchProfile(userData); // No user found if (data.UserData == null) { string msg = "miserable little failure"; } } catch (Exception ex) { string theEx = ex.InnerException.InnerException.Message; } }
public void TestLogin() { UserProfileRequest loginRequest = new UserProfileRequest { UserName = "******", }; var dataManager = new DataManager(); var result = dataManager.LoginToProfile(loginRequest); }
protected UserProfileResponse UpdateUserInformation(UserProfileRequest request) { return(GetUserProfileById(Guid.NewGuid())); }