private CneItemViewModel ToCneItemViewModel(
     CneIvssDataItem _cneIvssDataItem)
 {
     return(new CneItemViewModel
     {
         BirthDate = _cneIvssDataItem.BirthDate,
         CneIvssDataId = _cneIvssDataItem.CneIvssDataId,
         IdentificationCard = _cneIvssDataItem.IdentificationCard,
         IsCne = _cneIvssDataItem.IsCne,
         IsIvss = _cneIvssDataItem.IsIvss,
         NationalityDatas = _cneIvssDataItem.NationalityDatas,
         NationalityId = _cneIvssDataItem.NationalityId,
     });
 }
Exemplo n.º 2
0
 public CneItemViewModel ToCneItemViewModel(
     CneIvssDataItem _cneIvssData)
 {
     return(new CneItemViewModel
     {
         BirthDate = _cneIvssData.BirthDate,
         CneIvssDataId = _cneIvssData.CneIvssDataId,
         IdentificationCard = _cneIvssData.IdentificationCard,
         IsCne = _cneIvssData.IsCne,
         IsIvss = _cneIvssData.IsIvss,
         NationalityDatas = this.GetNationalityDatas(
             _cneIvssData.NationalityId),
         NationalityId = _cneIvssData.NationalityId,
     });
 }
Exemplo n.º 3
0
        private async void Save()
        {
            //  Validate the fields of the form
            if (this.NationalityId == 0)
            {
                await this.dialogService.ShowMessage(
                    "Error",
                    "You must select an nationality...!!!",
                    "Accept");

                return;
            }

            var response = MethodsHelper.IsValidField(
                "I",
                8,
                8,
                "identification card",
                this.IdentificationCard,
                true,
                false,
                string.Empty);

            if (!response.IsSuccess)
            {
                await this.dialogService.ShowMessage(
                    "Error",
                    response.Message,
                    "Accept");

                return;
            }

            //  Define the status of the controls
            this.SetStatusControl(false, true, 1);

            //  Check the connection internet
            response = await this.apiService.CheckConnection();

            if (!response.IsSuccess)
            {
                //  Define the status of the controls
                this.SetStatusControl(true, false, 0);
                await this.dialogService.ShowMessage(
                    "Error",
                    response.Message,
                    "Accept");

                return;
            }

            // Create the object
            var cneIvssData = new CneIvssDataItem
            {
                //  BirthDate = this.BirthDate,
                BirthDate          = DateTime.Today.Date,
                IdentificationCard = this.IdentificationCard,
                IsCne         = true,
                IsIvss        = false,
                NationalityId = this.NationalityId,
                UserId        = this.mainViewModel.UserData.UserId,
            };

            response = await this.apiService.Post <CneIvssDataItem>(
                MethodsHelper.GetUrlAPI(),
                "/api",
                "/CneIvssDatas/PostCneIvssDataInsertByOption/?_option=cne",
                mainViewModel.Token.TokenType,
                mainViewModel.Token.AccessToken,
                cneIvssData);

            if (!response.IsSuccess)
            {
                //  Define the status of the controls
                this.SetStatusControl(true, false, 0);
                await dialogService.ShowMessage(
                    "Error",
                    response.Message,
                    "Accept");

                return;
            }

            //  Add record to CneData
            this.cantvViewModel.UpdateCneData(
                1,
                this.ToCneItemViewModel((CneIvssDataItem)response.Result));

            //  Navigate to back
            await this.navigationService.GoBackOnMaster();

            //  Define the status of the controls
            this.SetStatusControl(true, false, 0);
        }
        private async void Delete()
        {
            if (await this.dialogService.ShowMessageConfirm(
                    "Infomation",
                    "Are you sure delete this record...?",
                    "Yes",
                    "No"))
            {
                //  Check the connections to internet
                var response = await this.apiService.CheckConnection();

                if (!response.IsSuccess)
                {
                    await this.dialogService.ShowMessage(
                        "Error",
                        response.Message,
                        "Accept");

                    return;
                }

                //  Generate an object
                var cneIvssDataItem = new CneIvssDataItem
                {
                    BirthDate          = this.BirthDate,
                    CneIvssDataId      = this.CneIvssDataId,
                    IdentificationCard = this.IdentificationCard,
                    IsCne            = this.IsCne,
                    IsIvss           = this.IsIvss,
                    NationalityDatas = this.NationalityDatas,
                    NationalityId    = this.NationalityId,
                    UserId           = this.mainViewModel.UserData.UserId,
                };

                //  Delete the record
                response = await this.apiService.Post <CneIvssDataItem>(
                    MethodsHelper.GetUrlAPI(),
                    "/api",
                    "/CneIvssDatas/PostCneIvssDataByOption/?_option=cne",
                    this.mainViewModel.Token.TokenType,
                    this.mainViewModel.Token.AccessToken,
                    cneIvssDataItem);

                if (!response.IsSuccess)
                {
                    await this.dialogService.ShowMessage(
                        "Error",
                        response.Message,
                        "Accept");

                    return;
                }

                //  Delete record
                this.cantvViewModel.UpdateCneData(
                    -1,
                    ToCneItemViewModel(cneIvssDataItem));

                await dialogService.ShowMessage(
                    "Infromation",
                    string.Format(
                        "Record: {0} remove successfully...!!!",
                        cneIvssDataItem.GetCneIvssFull),
                    "Accept");
            }
        }