public void CustomerDataTest_InvalidCompanyName()
        {
            UpdateProfileResponse r = new UpdateProfileResponse();

            string Country      = "US";
            string Language     = "ro";
            string FirstName    = "firstName";
            string LastName     = "lastName";
            bool   EmailOffers  = true;
            string PrimaryUse   = "Item005";
            string City         = "city";
            string Company      = ".HP Inc";
            bool   ActiveHealth = true;

            RESTAPICustomerData requestCustData = new RESTAPICustomerData()
            {
                Country      = Country,
                Language     = Language,
                FirstName    = FirstName,
                LastName     = LastName,
                EmailOffers  = EmailOffers,
                PrimaryUse   = PrimaryUse,
                City         = City,
                Company      = Company,
                ActiveHealth = ActiveHealth
            };

            ResponseBase response = new ResponseBase();

            Assert.IsFalse(requestCustData.IsValid(response));
            Assert.AreEqual(response.ErrorList.Count, 1);
            Assert.AreEqual(response.ErrorList.Where(x => x.DebugStatusText.Contains("Field has invalid format")).Count(), 1);
        }
示例#2
0
        public UpdateProfileResponse UpdateProfile(UpdateProfileRequest request)
        {
            UpdateProfileResponse response = new UpdateProfileResponse();

            response.Errors = new List <BusinessRule>();

            User user = _repository
                        .FindBy(request.UserId);

            if (user != null)
            {
                try
                {
                    user.FirstName   = request.Firstname;
                    user.LastName    = request.Lastname;
                    user.PhoneNumber = request.PhoneNumber;
                    user.BirthDay    = request.BirthDay;
                    _repository.Save(user);
                    _uow.Commit();

                    response.Result = true;
                }
                catch (Exception ex)
                {
                    response.Errors.Add(new BusinessRule("Error", ex.Message));
                    response.Result = false;
                }
            }
            else
            {
                response.Result = false;
            }

            return(response);
        }
        public void CustomerDataTest_Success()
        {
            UpdateProfileResponse r = new UpdateProfileResponse();

            string Country      = "US";
            string Language     = "ro";
            string FirstName    = "firstName";
            string LastName     = "lastName";
            bool   EmailOffers  = true;
            string PrimaryUse   = "Item002";
            string City         = "city";
            string Company      = "HP Inc";
            bool   ActiveHealth = true;

            RESTAPICustomerData requestCustData = new RESTAPICustomerData()
            {
                Country      = Country,
                Language     = Language,
                FirstName    = FirstName,
                LastName     = LastName,
                EmailOffers  = EmailOffers,
                PrimaryUse   = PrimaryUse,
                City         = City,
                Company      = Company,
                ActiveHealth = ActiveHealth
            };

            ResponseBase response = new ResponseBase();

            Assert.IsTrue(requestCustData.IsValid(response));
            Assert.AreEqual(response.ErrorList.Count, 0);
        }
        public UpdateProfileResponse UpdateProfile(UpdateProfileRequest request)
        {
            request.mobile_number = Common.GetStandardMobileNumber(request.mobile_number);
            UpdateProfileResponse response = new UpdateProfileResponse();

            try
            {
                if (!CheckAuthDriver(request.user_id, request.auth_token))
                {
                    MakeNoDriverResponse(response);
                    return(response);
                }
                using (DriverDao dao = new DriverDao())
                {
                    Driver driver = dao.FindById(request.user_id);
                    driver.DriverName = request.driver_name;
                    //driver.MobileNumber = request.mobile_number;
                    //driver.ProfileImage = request.profile_image; //Commented bcz image is uploading as multipart
                    dao.Update(driver);
                    response.code         = 0;
                    response.has_resource = 0;
                    response.message      = MessagesSource.GetMessage("profile.changed");
                    return(response);
                }
            }
            catch (Exception ex)
            {
                response.MakeExceptionResponse(ex);
                return(response);
            }
        }
示例#5
0
        /// <summary>
        /// Unmarshaller the response from the service to the response class.
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context)
        {
            UpdateProfileResponse response = new UpdateProfileResponse();


            return(response);
        }
示例#6
0
        public async Task <UpdateProfileResponse> UpdateProfile(UpdateProfileRequest request)
        {
            var response = new UpdateProfileResponse();
            var user     = await _sessionManager.GetUser();

            var dbRequest = new Repositories.DatabaseRepos.UserRepo.Models.UpdateUserRequest()
            {
                Id            = user.Id,
                Username      = request.Username,
                Email_Address = request.EmailAddress,
                First_Name    = request.FirstName,
                Last_Name     = request.LastName,
                Mobile_Number = request.MobileNumber,
                Updated_By    = user.Id
            };

            using (var uow = _uowFactory.GetUnitOfWork())
            {
                await uow.UserRepo.UpdateUser(dbRequest);

                uow.Commit();
            }

            await _sessionManager.DehydrateSession(); // user has changed

            await _sessionManager.WriteSessionLogEvent(new Models.ManagerModels.Session.CreateSessionLogEventRequest()
            {
                EventKey = SessionEventKeys.UserUpdatedProfile,
            });

            response.Notifications.Add("Profile updated successfully", NotificationTypeEnum.Success);
            return(response);
        }
示例#7
0
        public UpdateProfileResponse UpdateProfile(UpdateProfileRequest request)
        {
            UpdateProfileResponse response = new UpdateProfileResponse();

            User user = _userRepository.Get(request.Id);

            if (user == null)
            {
                response.HasError = true;
                return(response);
            }

            user.Email     = request.UsersUpdateModel.Email;
            user.FirstName = request.UsersUpdateModel.FirstName;
            user.LastName  = request.UsersUpdateModel.LastName;

            // Security Questions
            foreach (var question in request.UsersUpdateModel.SecurityQuestions.Where(q => q.Answer.IsNotNullOrEmpty()))
            {
                user.UpdateQuestion(question.Id, question.Question, question.Answer);
            }

            _roleRepository.Query().Where(r => r.CustomerId == request.CustomerId).ToList().Map(
                request.UsersUpdateModel.SelectedRoles,
                r => r.AddUser(user),
                r => r.RemoveUser(user)
                );

            _unitOfWork.Commit();

            return(response);
        }
        private async void SubmitButton_Clicked(object sender, EventArgs e)
        {
            try
            {
                if (!CrossConnectivity.Current.IsConnected)
                {
                    DependencyService.Get <IToast>().Show("No Network Connection!!");
                }
                else
                {
                    if (string.IsNullOrEmpty(_objEditProfileResponse.Response.details.Email) || string.IsNullOrEmpty(_objEditProfileResponse.Response.details.FirstName) ||
                        string.IsNullOrEmpty(_objEditProfileResponse.Response.details.MobileNumber))
                    {
                        DependencyService.Get <IToast>().Show("Email FirstName and Phone Number is  Required!!");
                    }
                    else
                    {
                        if (!IsValid)
                        {
                            DependencyService.Get <IToast>().Show("Email is not in a correct format!");
                        }
                        else
                        {
                            _objEditProfileResponse.Response.details.CountryId = Settings.CountryCode;
                            _objHeaderModel.TokenCode = Settings.TokenCode;
                            await Navigation.PushPopupAsync(new LoadingPopPage());

                            _objUpdateProfileResponse = await _apiService.UpdateProfileAsync(new Get_API_Url().CommonBaseApi(_baseUrlUpdate), true, _objHeaderModel, _objEditProfileResponse);

                            if (_objUpdateProfileResponse.StatusCode == 200)
                            {
                                Settings.Name = _objEditProfileResponse.Response.details.FirstName;
                                await Navigation.PopAllPopupAsync();

                                DependencyService.Get <IToast>().Show(_objUpdateProfileResponse.Message);

                                //var otherPage = new UserNavigationPage();
                                //var homePage = App.NavigationPage.Navigation.NavigationStack.First();
                                //App.NavigationPage.Navigation.InsertPageBefore(otherPage, homePage);
                            }
                            else
                            {
                                await Navigation.PopAllPopupAsync();

                                DependencyService.Get <IToast>().Show(_objUpdateProfileResponse.Message);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                var msg = ex.Message;
            }
        }
        public static UpdateProfileResponse Unmarshall(UnmarshallerContext context)
        {
            UpdateProfileResponse updateProfileResponse = new UpdateProfileResponse();

            updateProfileResponse.HttpResponse = context.HttpResponse;
            updateProfileResponse.Code         = context.StringValue("UpdateProfile.Code");
            updateProfileResponse.Data         = context.StringValue("UpdateProfile.Data");
            updateProfileResponse.Message      = context.StringValue("UpdateProfile.Message");
            updateProfileResponse.RequestId    = context.StringValue("UpdateProfile.RequestId");

            return(updateProfileResponse);
        }
示例#10
0
        public UpdateProfileResponse Process()
        {
            var response = new UpdateProfileResponse();

            var(status, cookies, requestVerificationToken) = _helperHandler.GetUserCookies(_phoneNumber, _password);
            if (!status)
            {
                return(response.ReturnWithCode(MessageHelper.Message(MessageHelper.Code.UpdateProfileInvalidUser)));
            }
            var updateProfileResponseCode = UpdateProfile(cookies, requestVerificationToken);

            return(response.ReturnWithCode(MessageHelper.Message(updateProfileResponseCode)));
        }
        public virtual async Task <UpdateProfileResponse> ChangePassword(ChangePasswordRequest request)
        {
            var response = new UpdateProfileResponse();
            var result   = await accountAppService.ChangePassWord(request);

            if (!result)
            {
                response.IsSuccess     = false;
                response.ErrorMesseage = new string[] { "Current password don't match/ confirm password don't match!" };
                return(response);
            }
            response.IsSuccess = true;
            response.userDto   = await accountAppService.GetAsync();

            return(response);
        }
示例#12
0
        /// <summary>
        /// Unmarshaller the response from the service to the response class.
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context)
        {
            UpdateProfileResponse response = new UpdateProfileResponse();

            context.Read();
            int targetDepth = context.CurrentDepth;

            while (context.ReadAtDepth(targetDepth))
            {
                if (context.TestExpression("ProfileId", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.ProfileId = unmarshaller.Unmarshall(context);
                    continue;
                }
            }

            return(response);
        }
示例#13
0
        public ActionResult Update(Guid id, UsersUpdateModel model)
        {
            var request = new UpdateProfileRequest
            {
                Id = id,
                UsersUpdateModel = model,
                CustomerId       = Customer.CustomerId
            };

            UpdateProfileResponse response = _userService.UpdateProfile(request);

            if (response.HasError)
            {
                return(HttpNotFound());
            }

            return(RedirectToAction("update", new { id })
                   .AndAlert(AlertType.Success, "Success.", "System user updated successfully."));
        }
        public virtual async Task <UpdateProfileResponse> UpdateProfile(UpdateProfileDto userDto)
        {
            var result = await accountAppService.UpdateProfile(userDto);

            var response = new UpdateProfileResponse
            {
                userDto = await accountAppService.GetAsync()
            };

            if (result)
            {
                response.IsSuccess = true;
            }
            else
            {
                response.IsSuccess     = false;
                response.ErrorMesseage = new string[] { "Update Failed!" };
            }
            return(response);
        }
        public async Task <UpdateProfileResponse> UpdateProfile(UpdateProfileRequest request)
        {
            var response = new UpdateProfileResponse();
            var session  = await _sessionService.GetAuthenticatedSession();

            var dbRequest = new Infrastructure.Repositories.UserRepo.Models.UpdateUserRequest()
            {
                Id                     = session.User.Entity.Id,
                Username               = request.Username,
                Email_Address          = request.EmailAddress,
                First_Name             = request.FirstName,
                Last_Name              = request.LastName,
                Mobile_Number          = request.MobileNumber,
                Password_Hash          = session.User.Entity.Password_Hash,
                Registration_Confirmed = session.User.Entity.Registration_Confirmed,
                Updated_By             = session.User.Entity.Id
            };

            if (!string.IsNullOrEmpty(request.Password))
            {
                dbRequest.Password_Hash = PasswordHelper.HashPassword(request.Password);
            }

            using (var uow = _uowFactory.GetUnitOfWork())
            {
                await uow.UserRepo.UpdateUser(dbRequest);

                uow.Commit();
            }

            // rehydrate user in session due to profile updating
            await _sessionService.RehydrateSession();

            await _sessionService.WriteSessionLogEvent(new Models.ServiceModels.Session.CreateSessionLogEventRequest()
            {
                EventKey = SessionEventKeys.UserUpdatedProfile
            });

            response.Notifications.Add("Profile updated successfully", NotificationTypeEnum.Success);
            return(response);
        }
示例#16
0
        public static async Task UpdateProfile(Profile profileInfo, Action <UpdateProfileResponse> successCallback, Action <ResponseBase> errorCallback)
        {
            RestRequest          request = new RestRequest("/lms/api/updateprofile", Method.PUT);
            UpdateProfileRequest _updateProfileRequest = new UpdateProfileRequest {
                UniqueAppId = App.UniqueAppId,
                UserName    = profileInfo.PersonalInfo.UserName,
                ProfileInfo = profileInfo
            };

            request.AddBody(_updateProfileRequest);
            Debug.WriteLine(JsonConvert.SerializeObject(_updateProfileRequest));
            UpdateProfileResponse response = await APIServiceProvider.ServiceProvider.Execute <UpdateProfileResponse> (request);

            if ((response != null) && (response.ResponseCode == "1000"))
            {
                successCallback?.Invoke(response);
            }
            else
            {
                errorCallback?.Invoke((ResponseBase)response);
            }
        }
 public UserProfilePage()
 {
     InitializeComponent();
     _objEditProfileResponse = new EditProfileResponse();
     _apiService             = new RestApi();
     _objHeaderModel         = new HeaderModel();
     _apiServices            = new RestApi();
     _objCountryListResponse = new CountryListResponse();
     _baseUrlEdit            = Settings.Url + Domain.EditUserApiConstant;
     _baseUrlUpdate          = Settings.Url + Domain.UpdateUserApiConstant;
     _baseUrl = Domain.GetCountryApiConstant;
     LoadUserProfileData();
     LoadCountryData();
     _objUpdateProfileResponse = new UpdateProfileResponse();
     if (Settings.ProfilePicture == string.Empty)
     {
         imgProfile.Source = "profile.png";
     }
     else
     {
         imgProfile.Source = Settings.ProfilePicture;
     }
 }
        public NegotiatedContentResult <UpdateProfileResponse> PostUpdateProfile([FromBody] UpdateProfileRequest request)
        {
            UpdateProfileResponse resp = _driverServices.UpdateProfile(request);

            return(Content(HttpStatusCode.OK, resp));
        }