public async Task <ActionResult> UpdateProfile(UpdateProfileInput input, CancellationToken cancellationToken) { var result = Ok(); var profile = await _userProfileService.GetProfileByUserIdAsync(UserId.ToUpper()); if (profile == null) { return(NotFound()); } var department = await _departmentsService.GetDepartmentByIdAsync(DepartmentId); var dm = await _departmentsService.GetDepartmentMemberAsync(UserId.ToUpper(), DepartmentId); var membership = _usersService.GetMembershipByUserId(UserId.ToUpper()); if (!String.IsNullOrWhiteSpace(input.Email) && membership.Email != input.Email) { membership.Email = input.Email; _usersService.SaveUser(membership); } if (!String.IsNullOrWhiteSpace(input.FirstName) && profile.FirstName != input.FirstName) { profile.FirstName = input.FirstName; } if (!String.IsNullOrWhiteSpace(input.LastName) && profile.LastName != input.LastName) { profile.LastName = input.LastName; } if (profile.IdentificationNumber != input.Id) { profile.IdentificationNumber = input.Id; } if (profile.HomeNumber != input.HomePhone) { profile.HomeNumber = input.HomePhone; } if (input.MobileCarrier != 0 && !String.IsNullOrWhiteSpace(input.MobilePhone)) { profile.MobileCarrier = input.MobileCarrier; profile.MobileNumber = input.MobilePhone; } profile.SendSms = input.SendCallSms; profile.SendPush = input.SendCallPush; profile.SendEmail = input.SendCallEmail; profile.SendMessageSms = input.SendMessageSms; profile.SendMessagePush = input.SendMessagePush; profile.SendMessageEmail = input.SendMessageEmail; profile.SendNotificationSms = input.SendNotificationSms; profile.SendNotificationPush = input.SendNotificationPush; profile.SendNotificationEmail = input.SendNotificationEmail; await _userProfileService.SaveProfileAsync(DepartmentId, profile, cancellationToken); _departmentsService.InvalidateDepartmentUsersInCache(department.DepartmentId); return(Ok(result)); }
public HttpResponseMessage UpdateProfile(UpdateProfileInput input) { var result = new HttpResponseMessage(HttpStatusCode.OK); var profile = _userProfileService.GetUserProfileForEditing(UserId.ToUpper()); if (profile == null) { throw HttpStatusCode.NotFound.AsException(); } var department = _departmentsService.GetDepartmentById(DepartmentId); var dm = _departmentsService.GetDepartmentMember(UserId.ToUpper(), DepartmentId); var membership = _usersService.GetMembershipByUserId(UserId.ToUpper()); if (!String.IsNullOrWhiteSpace(input.Email) && membership.Email != input.Email) { membership.Email = input.Email; _usersService.SaveUser(membership); } if (!String.IsNullOrWhiteSpace(input.FirstName) && profile.FirstName != input.FirstName) { profile.FirstName = input.FirstName; } if (!String.IsNullOrWhiteSpace(input.LastName) && profile.LastName != input.LastName) { profile.LastName = input.LastName; } if (profile.IdentificationNumber != input.Id) { profile.IdentificationNumber = input.Id; } if (profile.HomeNumber != input.HomePhone) { profile.HomeNumber = input.HomePhone; } if (input.MobileCarrier != 0 && !String.IsNullOrWhiteSpace(input.MobilePhone)) { profile.MobileCarrier = input.MobileCarrier; profile.MobileNumber = input.MobilePhone; } profile.SendSms = input.SendCallSms; profile.SendPush = input.SendCallPush; profile.SendEmail = input.SendCallEmail; profile.SendMessageSms = input.SendMessageSms; profile.SendMessagePush = input.SendMessagePush; profile.SendMessageEmail = input.SendMessageEmail; profile.SendNotificationSms = input.SendNotificationSms; profile.SendNotificationPush = input.SendNotificationPush; profile.SendNotificationEmail = input.SendNotificationEmail; _userProfileService.SaveProfile(DepartmentId, profile); _departmentsService.InvalidateDepartmentUsersInCache(department.DepartmentId); return(result); }