public ActionResult Login(string email, string password, string returnUrl = null) { ViewData["ReturnUrl"] = returnUrl; if (!string.IsNullOrWhiteSpace(email) && !string.IsNullOrWhiteSpace(password)) { UserProfileDTO userProfile = this.userRepository.GetUserByNameAndPassword(email, password); if (userProfile != null) { var principal = new ClaimsPrincipal(ClaimHelpers.ConstructClaimsIdentity(userProfile)); HttpContext.Authentication.SignInAsync("Cookies", principal); if (returnUrl != null) { if (returnUrl != null && returnUrl.Contains("Home/") || returnUrl.Contains("Users/Edit/0")) { return(RedirectToAction("Edit", "Users", new { @id = ClaimHelpers.GetUserIDClaimValue((ClaimsIdentity)principal.Identity) })); } return(LocalRedirect(returnUrl)); } else { return(RedirectToAction("Index", "Home")); } } } return(View()); }
public ActionResult Delete(int? id, bool? saveChangesError = false) { if (id == null) { return new HttpStatusCodeResult(HttpStatusCode.BadRequest); } if (saveChangesError.GetValueOrDefault()) { ViewBag.ErrorMessage = "Delete failed. Try again, and if the problem persists see your system administrator."; } UserProfileDTO userProfileDTO = _userProfileService.GetUserProfile(id); if (userProfileDTO == null) { return HttpNotFound(); } var userProfile = _mapper.Map<UserProfileDTO, UserProfileViewModel>(userProfileDTO); DirectionDTO directionDTO = _directionService.GetDirection(userProfileDTO.DirectionId); var direction = _mapper.Map<DirectionDTO, DirectionViewModel>(directionDTO); ViewBag.Direction = direction.Name; return View(userProfile); }
public ActionResult Edit(int id) { UserProfileDTO userProfileDTO = this.userRepository.GetUserByID(id); UserEditDetailedViewModel userDetailedViewModel = UserMapHelpers.MapUseProfileEditDetailedDTOToView(userProfileDTO); return(View(userDetailedViewModel)); }
//[ValidateAntiForgeryToken] public ActionResult Create(UserDetailedViewModel userForRegistrationViewModel) { try { if (ModelState.IsValid) { UserProfileDTO userProfile = new UserProfileDTO { FirstName = userForRegistrationViewModel.FirstName, LastName = userForRegistrationViewModel.LastName, Email = userForRegistrationViewModel.Email, Password = userForRegistrationViewModel.Password, Address = userForRegistrationViewModel.Address, PassportNumber = userForRegistrationViewModel.PassportNumber, PhoneNumber = userForRegistrationViewModel.PhoneNumber, IsActive = true, IsAdmin = userForRegistrationViewModel.IsAdmin }; userRepository.CreateUser(userProfile); return(RedirectToAction("Index", "Users")); } } catch (Exception ex) { ModelState.AddModelError(string.Empty, "Error!Sorry, something went wrong! Please retry the operation!"); return(View(userForRegistrationViewModel)); } finally { } return(View(userForRegistrationViewModel)); }
public bool UpdateProfile(UserProfileDTO userProfile, int userId) { if (FindByCondition(u => u.Email == userProfile.Email && u.Id != userProfile.Id).Any()) { return(false); } var user = Get(userProfile.Id); user.FirstName = userProfile.FirstName; user.LastName = userProfile.LastName; user.Email = userProfile.Email; user.UpdatedAt = DateTime.Now; user.UpdatedBy = userId; try { Save(); } catch (Exception) { return(false); } return(true); }
public UserProfileDTO GetUserProfile(string userName, string currectUserId) { var user = db.Users.FindByName(userName); var me = db.Users.FindById(currectUserId); if (user == null) { return(null); } var userProfile = new UserProfileDTO { Id = user.Id, UserName = user.UserName, FirstName = user.UserInfo.FirstName, LastName = user.UserInfo.LastName, DisplayName = user.DisplayName, Email = user.Email, Phone = user.UserInfo.Phone, Skype = user.UserInfo.Skype, AboutMe = user.UserInfo.AboutMe, AvatarFilename = user.UserInfo.AvatarFilename, IsOwner = user.Id == me.Id, IsFollowing = user.Followers.Any(u => u.Id == currectUserId), IsOnline = user.IsOnline }; return(userProfile); }
public IActionResult GetById(int id) { var user = _userService.GetById(id); if (user == null || user.Role != "Candidat") { return(Ok("Bad request")); } var rates = _context.Rate.Where(x => x.User_ToId == user.Id).ToList(); var ratesDTOLst = new List <RateDTO>(); foreach (var rate in rates) { ratesDTOLst.Add(new RateDTO { Stars = rate.Stars, Comment = rate.Comment }); } var model = new UserProfileDTO { Id = user.Id, FirstName = user.FirstName, LastName = user.LastName, Username = user.Username, Skillset = user.Skillset, Avaible = user.Avaible, Role = user.Role, Rates = ratesDTOLst, }; return(Ok(model)); }
public IActionResult GetProfile() { int id = int.Parse(User.Identity.Name); var user = _userService.GetById(id); var rates = _context.Rate.Where(x => x.User_ToId == user.Id).ToList(); var jobs = _context.Job.Where(x => ((User.IsInRole("Employer") || User.IsInRole("Admin")) ? x.EmployerID == id : x.CandidatID == id)).ToList(); var ratesDTOLst = new List <RateDTO>(); foreach (var rate in rates) { ratesDTOLst.Add(new RateDTO { JobDescription = "", Stars = rate.Stars, Comment = rate.Comment }); } for (int i = 0; i < ratesDTOLst.Count; i++) { ratesDTOLst[i].JobDescription = jobs[i].Description; } var model = new UserProfileDTO { Id = user.Id, FirstName = user.FirstName, LastName = user.LastName, Username = user.Username, Skillset = user.Skillset, Avaible = user.Avaible, Role = user.Role, Rates = ratesDTOLst, }; return(Ok(model)); }
public UserProfileDTO Update(UserProfileDTO newModel, string key, string IV) { try { var currentModel = GetByID(newModel.UserID); if (!string.IsNullOrEmpty(newModel.Password) && !string.IsNullOrWhiteSpace(newModel.Password)) { newModel.EncryptedPassword = CryptoService.Encrypt(newModel.Password, key, IV); } else { newModel.EncryptedPassword = currentModel.EncryptedPassword; } if (newModel.UserRoleTypeID != currentModel.UserRoleTypeID) { SetupUserClaims(newModel.UserID, newModel.UserRoleTypeID); } var returnModel = UOW.UserRepo.Update(newModel); UOW.SaveChanges(); return(returnModel); } catch (Exception ex) { UOW.RollbackChanges(); throw ex; } }
public IHttpActionResult GetUserProfile() { try { profilesService = new ProfilesService(User.Identity.Name); } catch (UserNotFoundException) { return(NotFound()); } UserProfile userProfile = profilesService.Get(); UserProfileDTO userProfileDTO = new UserProfileDTO() { FirstName = userProfile.FirstName, LastName = userProfile.LastName, PhotoURL = userProfile.PhotoURL, Email = userProfile.Email, PhoneNumber = userProfile.PhoneNumber, Country = userProfile.Country, City = userProfile.City, Address = userProfile.Address }; return(Ok(userProfileDTO)); }
public async Task <IHttpActionResult> EditUserProfile(UserProfileDTO userprofileDTO) { try { var userStore = new UserStore <ApplicationUser>(new ApplicationDbContext()); var manager = new UserManager <ApplicationUser>(userStore); var currentUser = manager.FindById(userprofileDTO.UserId); currentUser.FirstName = userprofileDTO.FirstName; currentUser.LastName = userprofileDTO.LastName; currentUser.PhoneNumber = userprofileDTO.PhoneNumber; var result = await manager.UpdateAsync(currentUser); var ctx = userStore.Context; ctx.SaveChanges(); if (result.Succeeded) { return(ResponseMessage(Request.CreateErrorResponse(HttpStatusCode.Accepted, "User profile Updated"))); } else { return(ResponseMessage(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "User profile Failed"))); } } catch (Exception ex) { return(ResponseMessage(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "User profile Failed"))); } }
public async Task<OperationDetails> EditProfile(UserProfileDTO model) { User user = await Database.UserManager.FindByIdAsync(model.UserId); UserProfile profile = Database.UserProfileRepository.GetById(user.ProfileId); if (model.UserName != null) { User clone = await Database.UserManager.FindByNameAsync(model.UserName); if (model.UserName != user.UserName && clone != null) return new OperationDetails(false, "Username is being use", ""); user.UserName = model.UserName; } if (model.Email != null) { User clone = await Database.UserManager.FindByEmailAsync(model.Email); if (model.Email != user.Email && clone != null) return new OperationDetails(false, "Username is being use", ""); user.Email = model.Email; } user.PhoneNumber = model.PhoneNumber; profile.Birthday = model.Birthday; if (model.Country != null && model.City != null) { Location location = new Location { City = model.City, Country = model.Country }; if (Database.LocationRepository.FindClone(location) == null) { Location newlocation = Database.LocationRepository.Create(location); profile.Location = newlocation; } } await Database.SaveAsync(); return new OperationDetails(true, "Ok", ""); }
// CRUD methods. public async Task <OperationDetails> CreateAsync(UserProfileDTO userProfileDTO) { ApplicationUser user = await Database.UserManager.FindByEmailAsync(userProfileDTO.Email); if (user == null) { user = new ApplicationUser { Email = userProfileDTO.Email, UserName = userProfileDTO.UserName }; var result = await Database.UserManager.CreateAsync(user, userProfileDTO.Password); if (result.Errors.Count() > 0) { return(new OperationDetails(false, result.Errors.FirstOrDefault(), "Method - UserService.CreateAsync()")); } // Add role. await Database.UserManager.AddToRoleAsync(user.Id, userProfileDTO.Role); // Create user profile. UserProfile userProfile = new UserProfile { UserProfileId = user.Id, Address = userProfileDTO.Address }; Database.UserProfile.Create(userProfile); await Database.SaveAsync(); return(new OperationDetails(true, "Registration completed successfully.", "")); } else { return(new OperationDetails(false, "User with this email already exists.", "Email")); } }
public ActionResult <string> UpdateProfile(UserProfileDTO userProfileDTO) { var user = _userService.GetUserByEmail(HttpContext.User.Identity.Name); if (user != null) { var userNameValid = userProfileDTO.Name.Length > 0; if (!userNameValid) { return(BadRequest("Wrong username")); } user.Name = userProfileDTO.Name; user.Avatar = userProfileDTO.Avatar; _userService.UpdateUser(user); _userService.SaveChanges(); _authService.Login(HttpContext, user); return(Ok("User profile updated")); } return(Unauthorized("Access denied")); }
public async Task <ActionResult> Register(RegisterUserModel model) { // default role var defaultRoleName = "User"; //await SetInitialDataAsync(); if (ModelState.IsValid) { var userDto = new UserCredentialsDTO { Email = model.Email, Password = model.Password, UserName = model.UserName, Role = defaultRoleName }; var profileDto = new UserProfileDTO { JoinDate = model.JoinDate, BirthDate = model.BirthDate, Location = model.Location }; OperationDetails operationDetails = await UserService.Create(userDto, profileDto); if (operationDetails.Succeeded) { return(View("RegisterSuccess")); } else { ModelState.AddModelError(operationDetails.Error.PropertyName, operationDetails.Error.DescriptionMessage); } } return(View(model)); }
public async Task <IActionResult> StartChatWithUser([FromBody] UserProfileDTO user) { var d = await chatService.StartChatWithUser(user); return(d == null?StatusCode(409) as IActionResult : Ok(d)); }
public ActionResult Edit(long id = 0) { UserProfileDTO profile = InsuranceBusiness.BusinessLayer.GetUserProfile(id); UserProfileModelObject model = new UserProfileModelObject() { Active = profile.Active, Address = profile.Address, Birthdate = profile.Birthdate, ContactEmail = profile.ContactEmail, FirstName = profile.FirstName, LastName = profile.LastName, ID = profile.ID, ID_User = profile.ID_User, Role = new RoleModelObject() { Id = profile.Role.Id }, User = new UserModelObject() { Email = profile.User.Email, EmailConfirmed = profile.User.EmailConfirmed, LockoutEnabled = profile.User.LockoutEnabled, LockoutEndDateUtc = profile.User.LockoutEndDateUtc, Id = profile.User.Id, UserName = profile.User.UserName } }; return(PartialView(model)); }
public JsonResponse <UserProfileDTO> DisplayRaceUserProfile(long userID) { JsonResponse <UserProfileDTO> response = new JsonResponse <UserProfileDTO>(); try { ExceptionEngine.AppExceptionManager.Process(() => { UserProfileDTO objUserProfileDTO = new UserProfileDTO(); UserProfileBO objUserProfileBO = UserBusinessInstance.DisplayUserProfile(userID); EntityMapper.Map(objUserProfileBO, objUserProfileDTO); if (objUserProfileDTO.UserID > 0) { response.IsSuccess = true; response.SingleResult = objUserProfileDTO; } else { response.IsSuccess = false; response.Message = Messages.InvalidUserID; } }, AspectEnums.ExceptionPolicyName.ServiceExceptionPolicy.ToString()); } catch (Exception ex) { response.Message = ex.Message; } return(response); }
public async Task <ActionResult> Edit(UserProfileModelObject model, HttpPostedFileBase fileUploaderControl) { try { UserProfileDTO profile = InsuranceBusiness.BusinessLayer.GetUserProfile(model.ID); profile.FirstName = model.FirstName; profile.LastName = model.LastName; //profile.User.EmailConfirmed = model.User.EmailConfirmed; InsuranceBusiness.BusinessLayer.UpdateProfile(profile); UserProfileDTO user = InsuranceBusiness.BusinessLayer.GetUserProfile(model.ID_User); if (user.Role.Id != model.Role.Id) { RoleDTO roleToRemove = InsuranceBusiness.BusinessLayer.GetRoles().FirstOrDefault(i => i.Id == user.Role.Id); var result = await this.UserManager.RemoveFromRoleAsync(model.ID_User, roleToRemove.Name); RoleDTO roleToAssign = InsuranceBusiness.BusinessLayer.GetRoles().FirstOrDefault(i => i.Id == model.Role.Id); result = await this.UserManager.AddToRoleAsync(model.ID_User, roleToAssign.Name); } } catch (Exception ex) { InsuranceBusiness.BusinessLayer.LogException(string.Format("{0} [{1}]", Request.UserHostAddress, model.ID_User), string.Format("{0}.{1}", this.ControllerContext.RouteData.Values["controller"].ToString(), this.ControllerContext.RouteData.Values["action"].ToString()), ex); return(View("Error")); } return(RedirectToAction("Index")); }
public static UserTokenDTO BuildToken(UserProfileDTO userProfile) { var claims = new List <Claim> { new Claim(JwtRegisteredClaimNames.Jti, userProfile.Id), new Claim(ClaimTypes.Name, userProfile.Name), new Claim(ClaimTypes.Surname, userProfile.Surname), new Claim(ClaimTypes.Email, userProfile.Email), new Claim(ClaimTypes.MobilePhone, userProfile.PhoneNumber), new Claim("AdsAmount", userProfile.AdsAmount.ToString()), new Claim("ComentsAmount", userProfile.ComentsAmount.ToString()) }; var key = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(JwtOptions.KEY)); var creds = new SigningCredentials(key, SecurityAlgorithms.HmacSha256); var expiration = DateTime.UtcNow.AddDays(JwtOptions.LIFETIME); JwtSecurityToken token = new JwtSecurityToken( issuer: JwtOptions.ISSUER, audience: JwtOptions.AUDIENCE, claims: claims, expires: expiration, signingCredentials: creds); return(new UserTokenDTO() { AccessToken = new JwtSecurityTokenHandler().WriteToken(token) }); }
private void FillModel(ProfileViewModel model, string userId, bool getUserPosts = true) { model.Profile = InsuranceBusiness.BusinessLayer.GetUserProfile(userId); if (null == model.Profile.ProfilePhoto || model.Profile.ProfilePhoto.Length == 0) { Image img = Image.FromFile(Server.MapPath("/Content/images/no_photo_img.jpg")); using (MemoryStream ms = new MemoryStream()) { img.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg); model.Profile.ProfilePhoto = ms.ToArray(); } } CurrentUser = model.Profile; model.Notifications = InsuranceBusiness.BusinessLayer.GetUserNotifications(userId); model.TotalUnreadMessages = InsuranceBusiness.BusinessLayer.GetTotalUnreadMessages(userId); if (model is HomeViewModel) { if (((HomeViewModel)model).IsPostsView && getUserPosts) { ((HomeViewModel)model).Posts = InsuranceBusiness.BusinessLayer.GetUserRelatedPosts(userId); } ((HomeViewModel)model).TopBanners = InsuranceBusiness.BusinessLayer.GetActiveBanners(BannerTypeEnum.WEB_PRINCIPAL_BANNER); ((HomeViewModel)model).SideBanners = InsuranceBusiness.BusinessLayer.GetActiveBanners(BannerTypeEnum.WEB_SECONDARY_BANNER); } else if (model is MessagesViewModel) { ((MessagesViewModel)model).Chats = InsuranceBusiness.BusinessLayer.GetChats(userId); } }
private void MapUserProfileDToToEntity(UserProfileDTO userProfile, User user) { user.Email = userProfile.Email; user.FirstName = userProfile.FirstName; user.LastName = userProfile.LastName; if (!string.IsNullOrEmpty(userProfile.Password)) { user.PasswordHash = HashHelper.GetHashedString(userProfile.Password); } user.Address = userProfile.Address; user.PassportNumber = userProfile.PassportNumber; user.PhoneNumber = userProfile.PhoneNumber; var userRoles = user.UserRoles.ToList(); if (userProfile.IsAdmin && !userRoles.Any(ur => ur.RoleID == (int)RolesEnum.Admin)) { user.UserRoles.Add(new UserRole { RoleID = (int)RolesEnum.Admin, User = user }); } else if (!userProfile.IsAdmin && userRoles.Any(ur => ur.RoleID == (int)RolesEnum.Admin)) { UserRole adminRole = userRoles.Where(ur => ur.RoleID == (int)RolesEnum.Admin).Single(); this.Context.UserRoles.Remove(adminRole); } }
public AuthenticatedUserDTO ExchangeKeyForToken(string exchangeKey, string username) { AuthenticatedUserDTO returnUser = new AuthenticatedUserDTO(); UserProfileDTO searchResult = _securityService.GetUserProfile(username); if (searchResult != null) { if (_securityService.VerifyAccessKey(exchangeKey)) { var claims = _securityService.GetUserClaims(username); if (claims != null) { string userJWTToken = BuildUserJwtToken(username, claims); if (!string.IsNullOrEmpty(userJWTToken)) { returnUser = new AuthenticatedUserDTO(); returnUser.RefreshToken = BuildRefreshToken(username); returnUser.BearerToken = userJWTToken; returnUser.IsAuthenticated = true; returnUser.Username = username; foreach (var claim in claims) { returnUser.UserClaims.Add(claim); } } } } } return(returnUser); }
//[ValidateAntiForgeryToken] public ActionResult Edit(int id, UserEditDetailedViewModel userForEditViewModel) { try { if (ModelState.IsValid) { UserProfileDTO userProfile = UserMapHelpers.MapUseProfileDetailedViewToDTO(userForEditViewModel); UserProfileDTO editedUserProfileDTO = userRepository.EditUser(userProfile); UserEditDetailedViewModel editedUserDetailedViewModel = UserMapHelpers.MapUseProfileEditDetailedDTOToView(editedUserProfileDTO); if (User.IsUserAdmin()) { return(RedirectToAction("Index", "Users")); } //return RedirectToAction("Edit", "Users", new { @id = id }); return(RedirectToAction("Index", "Home")); } } catch (Exception ex) { ModelState.AddModelError(string.Empty, "Error!Sorry, something went wrong! Please retry the operation!"); return(View(userForEditViewModel)); } finally { } return(View(userForEditViewModel)); }
public IHttpActionResult PutUser([FromBody] UserProfileDTO userDto) { if (userDto == null) { return(BadRequest("Content was null")); } if (User.Identity.GetUserId() != userDto.UserId) { throw new HttpResponseException(HttpStatusCode.Unauthorized); } using (var client = new UsersDbContext()) { var userProfile = client.Set <UserProfile>().Find(userDto.UserId); if (userProfile == null) { return(BadRequest($"User profile not found. id={userDto.UserId}")); } userProfile.Firstname = userDto.Firstname; userProfile.Lastname = userDto.Lastname; userProfile.MemberId = userDto.MemberId; userProfile.ProfileText = userDto.ProfileText; var user = client.Set <IdentityUser>().Find(userDto.UserId); user.Email = userDto.Email; client.SaveChanges(); } return(Ok(userDto)); }
public async Task <UserProfileDTO> GetUserById(string Id) { string serializedUser = JsonConvert.SerializeObject(""); var requestMessage = new HttpRequestMessage(HttpMethod.Get, "GetById/" + Id); requestMessage.Content = new StringContent(serializedUser); requestMessage.Content.Headers.ContentType = new MediaTypeHeaderValue("application/json"); string accessToken = await localStorageService.GetItemAsync <string>("accessToken"); requestMessage.Headers.Authorization = new AuthenticationHeaderValue("Bearer", accessToken); var response = await httpClient.SendAsync(requestMessage); UserProfileDTO savedResult = new UserProfileDTO(); var errorMessage = new Regex("(?<=error_description=\").*(?=;)").Match(response.Headers.WwwAuthenticate.ToString()); if (errorMessage.Value == "The token lifetime is invalid" && response.StatusCode.ToString() == "Unauthorized") { string refreshToken = await localStorageService.GetItemAsync <string>("refreshToken"); //await tokenServices.RefreshToken(new UserTokenDTO() { AccessToken = accessToken, RefreshToken = refreshToken }); savedResult = await GetUserByAccessToken(accessToken); // call method again after refresh token } else { var responseBody = await response.Content.ReadAsStringAsync(); return(JsonConvert.DeserializeObject <UserProfileDTO>(responseBody)); } return(savedResult); }
public async Task <ActionResult> Register(RegistryViewModel model) { //await SetInitialDataAsync(); if (ModelState.IsValid) { UserProfileDTO userDto = new UserProfileDTO { Email = model.Email, Password = model.Password, Address = model.Address, UserName = model.Name, Role = "user" }; OperationDetails operationDetails = await UserService.CreateAsync(userDto); if (operationDetails.Succedeed) { return(View("SuccessRegister")); } else { ModelState.AddModelError(operationDetails.Property, operationDetails.Message); } } return(View(model)); }
public async Task <ActionResult> Login(LoginViewModel model) { //await SetInitialDataAsync(); if (ModelState.IsValid) { UserProfileDTO userDto = new UserProfileDTO { Email = model.Email, Password = model.Password }; ClaimsIdentity claim = await UserService.AuthenticateAsync(userDto); if (claim == null) { ModelState.AddModelError("", "Wrong login or password."); } else { AuthenticationManager.SignOut(); AuthenticationManager.SignIn(new AuthenticationProperties { IsPersistent = true }, claim); if (Request.QueryString.GetValues("ReturnUrl") != null) { string backRef = Request.QueryString.GetValues("ReturnUrl")[0]; // Return to the back reference. return(Redirect(backRef)); } return(RedirectToAction("Index", "Home")); } } return(View(model)); }
public UserProfileDTO Update(UserProfileDTO updatedRecord) { try { string query = @" UPDATE Users SET Username = @Username, EncryptedPassword = @EncryptedPassword, KnownAs = @KnownAs, EmailAddress = @EmailAddress, UserRoleTypeID = @UserRoleTypeID WHERE UserID = @UserID"; var queryParameters = new DynamicParameters(); queryParameters.Add("@Username", updatedRecord.Username); queryParameters.Add("@EncryptedPassword", updatedRecord.EncryptedPassword); queryParameters.Add("@KnownAs", updatedRecord.KnownAs); queryParameters.Add("@EmailAddress", updatedRecord.EmailAddress); queryParameters.Add("@UserID", updatedRecord.UserID); queryParameters.Add("@UserRoleTypeID", updatedRecord.UserRoleTypeID); int rowsUpdated = Connection.Execute(query, queryParameters, CurrentTrans); return((rowsUpdated > 0) ? GetByID(updatedRecord.UserID) : throw noRecordEX); } catch (Exception ex) { throw SqlExceptionHandler.HandleSqlException(ex) ?? ex; } }
public HttpResponseMessage UpdateUserProfile(UserProfileDTO dto) { var upc = new UserProfileController(); var up = upc.Profiles_Get(PortalSettings.PortalId, ActiveModule.ModuleID, dto.UserId); if (up == null) { return(Request.CreateResponse(HttpStatusCode.NotFound)); } if (dto.TrustLevel.HasValue) { up.TrustLevel = dto.TrustLevel.Value; } up.UserCaption = dto.UserCaption; up.Signature = dto.Signature; if (dto.RewardPoints.HasValue) { up.RewardPoints = dto.RewardPoints.Value; } upc.Profiles_Save(up); return(Request.CreateResponse(HttpStatusCode.OK)); }
public static OperationResponse SaveUserProfile(this MainForm mainForm, UserProfileDTO profile) { return ClientProxy.InvokeOperation(new OperationRequest() { TargetOperationId = SpringOperation.UserProfileOperation, TargetMethod = OperationMethod.SaveOrUpdate, OperationArgs = new object[] { profile } }); }
public HttpResponseMessage UpdateUserProfile(UserProfileDTO dto) { var upc = new UserProfileController(); var up = upc.Profiles_Get(PortalSettings.PortalId, ActiveModule.ModuleID, dto.UserId); if (up == null) return Request.CreateResponse(HttpStatusCode.NotFound); if (dto.TrustLevel.HasValue) up.TrustLevel = dto.TrustLevel.Value; up.UserCaption = dto.UserCaption; up.Signature = dto.Signature; if (dto.RewardPoints.HasValue) up.RewardPoints = dto.RewardPoints.Value; upc.Profiles_Save(up); return Request.CreateResponse(HttpStatusCode.OK); }
public void CreateTestMethod() { UserDTO user = new UserDTO() { Name = "dragon.luo", Password = "******", Email = "*****@*****.**", Mobile = "15913135166", EffectiveDate = DateTime.Now, ExpiryDate = DateTime.Now.AddYears(5), }; user.Roles = new List<RoleDTO>() { new RoleDTO() { Name = "Administrator" } }; response = InvokeOperation("userOperation", "Create", new object[] { user }); user = new UserDTO() { Name = "diana.wu", Password = "******", Email = "*****@*****.**", Mobile = "13570497968", EffectiveDate = DateTime.Now, ExpiryDate = DateTime.Now.AddYears(5), }; user.Roles = new List<RoleDTO>() { new RoleDTO() { Name = "General User" }, new RoleDTO() { Name = "System Configuration Management" } }; response = InvokeOperation("userOperation", "Create", new object[] { user }); response = InvokeOperation("roleOperation", "Retrieve", new object[] { 100003 }); ; RoleDTO role = response.Result.Value as RoleDTO; user = new UserDTO() { Name = "admin", Password = "******", Email = "*****@*****.**", Mobile = "1234567890A", EffectiveDate = DateTime.Now, ExpiryDate = DateTime.Now.AddYears(5), }; role.Remark = "testing reamrk"; user.Roles = new List<RoleDTO>() { role }; JsonConfigDTO jsonConfig = new JsonConfigDTO() { DefaultModuleId = 2, WindowTheme = "Office2010Blue" }; UserProfileDTO profile = new UserProfileDTO() { JsonConfig = JsonUtils.SerializeObject(jsonConfig), Owner = user, ProfileType = "Personal", StartDate = DateTime.Now }; user.Profiles.Add(profile); response = InvokeOperation("userOperation", "Create", new object[] { user }); }