private async void Register()
        {
            bool isValidateName = Unities.ValidateName(FirstName);

            if (!isValidateName)
            {
                FirstName = "";
            }
            bool isValidateLastName = Unities.ValidateName(LastName);

            if (!isValidateLastName)
            {
                LastName = "";
            }
            bool isValidateDate = Unities.ValidateStringDateFormat(BirthDate);

            if (!isValidateDate)
            {
                BirthDate = "";
            }
            bool isValidateEmail = Unities.CheckEmailFormat(Email);

            if (!isValidateEmail)
            {
                Email = "";
            }
            if (!string.IsNullOrEmpty(MobileNumber))
            {
                MobileNumber = Regex.Replace(MobileNumber, @"[^\d]", "");
            }
            bool isValidatePhoneNumber = Unities.ValidateStringMobile(MobileNumber);

            if (!isValidatePhoneNumber)
            {
                MobileNumber = "";
            }
            if (isValidateName && isValidateLastName && isValidateDate && isValidateEmail && isValidatePhoneNumber)
            {
                RegisterCommand register = new RegisterCommand
                {
                    BirthDate    = DateTime.ParseExact(BirthDate, "dd/MM/yyyy", null),
                    Email        = Email,
                    FirstName    = FirstName,
                    LastName     = LastName,
                    Pin          = Pin,
                    MobileNumber = MobileNumber,
                    Gender       = Gender
                };
                SetPinForAuthViewModel authViewModel = new SetPinForAuthViewModel(register);

                await Application.Current.MainPage.Navigation.PushAsync(new PinPage(authViewModel));
            }
            else
            {
                await PopupNavigation.PushAsync(new Error(new ErrorViewModel("กรอกข้อมูลไม่ถูกต้อง", (int)EW_Enumerations.EW_ErrorTypeEnum.Warning)));
            }
        }
예제 #2
0
        private async void Edit()
        {
            if (IsEditMode)
            {
                bool isValidateName     = Unities.ValidateName(FirstName);
                bool isValidateLastName = Unities.ValidateName(LastName);
                bool isValidateDate     = Unities.ValidateStringDateFormat(BirthDate);
                bool isValidateEmail    = Unities.CheckEmailFormat(Email);
                bool isValidatePhoneNum = Unities.ValidateStringMobile(MobileNumber);
                if (isValidateName && isValidateLastName && isValidateDate && isValidateEmail && isValidatePhoneNum)
                {
                    UpdateUserCommand updateUserCommand = new UpdateUserCommand
                    {
                        BitrhDate    = DateTime.ParseExact(BirthDate, "dd/MM/yyyy", null),
                        Email        = Email,
                        FirstName    = FirstName,
                        LastName     = LastName,
                        MobileNumber = MobileNumber,
                        Gender       = Gender
                    };
                    var editResult = await _userService.UpdateUser(updateUserCommand);

                    bool isError = editResult.IsError;
                    if (isError)
                    {
                        await PopupNavigation.PushAsync(new Error(new ErrorViewModel("Error", (int)EW_Enumerations.EW_ErrorTypeEnum.Warning)));
                    }
                    else
                    {
                        //TODO: Show Completed Popup
                        StoreValue(updateUserCommand);

                        IsEditMode     = false;
                        ShowEditButton = true;
                        await PopupNavigation.PushAsync(new SavedProfile());

                        Application.Current.MainPage.Navigation.PushAsync(new EditProfilePage());
                    }
                }
                else
                {
                    await PopupNavigation.PushAsync(new Error(new ErrorViewModel("กรอกข้อมูลไม่ถูกต้อง", (int)EW_Enumerations.EW_ErrorTypeEnum.Warning)));
                }
            }
            else
            {
                IsEditMode     = true;
                ShowEditButton = false;
            }
        }