Пример #1
0
        public async Task <dynamic> AddLicence(ContactLicence licence)
        {
            var result = await _requestService.postDataFromServiceAuthority("api/CandidateDetails/AddEditContactLicences", licence);

            return(result);
        }
Пример #2
0
        private async Task BtnSaveLicenceCommandAsync()
        {
            ContactLicence licence = new ContactLicence
            {
                MeasurementName   = _type,
                MeasurementNumber = _number.ToString(),
                Description       = _comment,
                From           = _fromDate,
                DateFromString = _fromDate.HasValue ? _fromDate.Value.ToString("dd/MM/yyyy", CultureInfo.InvariantCulture) : "",
                To             = _toDate,
                DateToString   = _toDate.HasValue ? _toDate.Value.ToString("dd/MM/yyyy", CultureInfo.InvariantCulture) : "",
            };
            var pop = await _dialogService.OpenLoadingPopup();

            Dictionary <string, object> obj = await _candidateDetailsService.AddLicence(licence);

            if (obj != null)
            {
                try
                {
                    if (obj["Success"].ToString() == "true") //success
                    {
                        await _dialogService.PopupMessage("Add new Licence Successefully", "#52CD9F", "#FFFFFF");

                        if (stream != null)
                        {
                            Dictionary <string, object> objupload = await _candidateDetailsService.SaveContactLicenceAttachment(obj["Result"].ToString(), stream);

                            if (objupload != null)
                            {
                                try
                                {
                                    if (objupload["Success"].ToString() == "true") //success
                                    {
                                        await _dialogService.PopupMessage("Attach file Successefully", "#52CD9F", "#FFFFFF");

                                        await PopupNavigation.Instance.PopAllAsync();

                                        await _navigationService.NavigateToAsync <CandidateMainViewModel>();
                                    }
                                    else if (objupload["Success"].ToString() == "false")
                                    {
                                        if (objupload["Message"].ToString() == "Fail")
                                        {
                                            await _dialogService.PopupMessage("An error has occurred, please try again!!", "#CF6069", "#FFFFFF");
                                        }
                                        else if (objupload["Message"].ToString() == "NodocumentFile")
                                        {
                                            await _dialogService.PopupMessage("Attach file Fail, please try again!!", "#CF6069", "#FFFFFF");
                                        }
                                    }
                                }
                                catch
                                {
                                    await _dialogService.PopupMessage("An error has occurred, please try again!!", "#CF6069", "#FFFFFF");

                                    await _dialogService.CloseLoadingPopup(pop);
                                }
                            }
                        }
                        else
                        {
                            await PopupNavigation.Instance.PopAllAsync();

                            await _navigationService.NavigateToAsync <CandidateMainViewModel>();
                        }
                    }
                }
                catch
                {
                    await _dialogService.PopupMessage("An error has occurred, please try again!!", "#CF6069", "#FFFFFF");

                    await _dialogService.CloseLoadingPopup(pop);
                }
            }
            await _dialogService.CloseLoadingPopup(pop);
        }