public async Task <NewPartnerResponseModel> PostNewPartnerAsync(NewPartnerRequestModel inModel, string sessionId, string RequestType)
        {
            NewPartnerResponseModel outModel = null;

            try
            {
                string url     = string.Format(Configuration.PostNewPartnerUrl, sessionId);
                string content = JsonConvert.SerializeObject(inModel);

                var value = await App.kegIDClient.ExecuteServiceCall <KegIDResponse>(url, HttpMethodType.Send, content, RequestType : RequestType);

                outModel = !string.IsNullOrEmpty(value.Response) ? App.kegIDClient.DeserializeObject <NewPartnerResponseModel>(value.Response) : new NewPartnerResponseModel();
                if (outModel != null)
                {
                    outModel.Response = new KegIDResponse
                    {
                        StatusCode = value.StatusCode
                    };
                }
            }
            catch (System.Exception)
            {
            }
            return(outModel);
        }
Esempio n. 2
0
        public async Task <HttpResponseMessage> PostNewPartner(NewPartnerRequestModel model, string sessionId)
        {
            var cts  = new CancellationTokenSource();
            var task = RemoteRequestAsync(_moveApi.GetApi(Priority.UserInitiated).PostNewPartner(model, sessionId, cts.Token));

            runningTasks.Add(task.Id, cts);

            return(await task);
        }
        private async void SubmitCommandRecieverAsync()
        {
            NewPartnerRequestModel newPartnerRequestModel = new NewPartnerRequestModel
            {
                AccountNumber   = AccountNumber,
                BillAddress     = BillAddress,
                ContactEmail    = ContactEmail,
                ContactName     = ContactName,
                Fax             = Fax,
                IsInternal      = IsInternalOn,
                IsNotify        = IsNotify,
                IsShared        = IsSharedOn,
                LocationCode    = LocationCode,
                LocationStatus  = LocationStatus,
                Notes           = Notes,
                FirstName       = PartnerName,
                LastName        = PartnerName,
                ParentPartnerId = IsInternalOn ? AppSettings.CompanyId : _uuidManager.GetUuId(),
                PartnerId       = _uuidManager.GetUuId(),
                PartnerName     = PartnerName,
                PartnerTypeCode = SelectedPartnerType.Code,
                Phone           = Phone,
                PrivateKey      = PrivateKey,
                ReferenceKey    = ReferenceKey,
                RouteName       = RouteName,
                ShipAddress     = ShipAddress,
                SmsAddress      = SmsAddress,
                TimeZone        = "+05:30", //PTTimeZone;
                Website         = ""        //Website;
            };

            try
            {
                Loader.StartLoading();
                var result = await _moveService.PostNewPartnerAsync(newPartnerRequestModel, AppSettings.SessionId, RequestType : Configuration.NewPartner);

                if (result != null)
                {
                    try
                    {
                        PartnerModel partnerModel = new PartnerModel
                        {
                            Address             = BillingAddress,
                            Address1            = ShippingAddress,
                            City                = newPartnerRequestModel.BillAddress != null ? newPartnerRequestModel.BillAddress.City : string.Empty,
                            ParentPartnerId     = newPartnerRequestModel.ParentPartnerId,
                            ParentPartnerName   = newPartnerRequestModel.PartnerName,
                            PartnerId           = newPartnerRequestModel.PartnerId,
                            PartnershipIsActive = newPartnerRequestModel.IsInternal,
                            IsInternal          = newPartnerRequestModel.IsInternal,
                            IsShared            = newPartnerRequestModel.IsShared,
                            Lat             = newPartnerRequestModel.BillAddress != null ? newPartnerRequestModel.BillAddress.Latitude : default(double),
                            LocationCode    = newPartnerRequestModel.LocationCode,
                            LocationStatus  = newPartnerRequestModel.LocationStatus,
                            Lon             = newPartnerRequestModel.BillAddress != null ? newPartnerRequestModel.BillAddress.Longitude : default(double),
                            MasterCompanyId = newPartnerRequestModel.ParentPartnerId,
                            PartnerTypeCode = newPartnerRequestModel.PartnerTypeCode,
                            PartnerTypeName = newPartnerRequestModel.PartnerName,
                            PhoneNumber     = newPartnerRequestModel.PartnerName,
                            PostalCode      = newPartnerRequestModel.BillAddress != null ? newPartnerRequestModel.BillAddress.PostalCode : string.Empty,
                            SourceKey       = newPartnerRequestModel.RouteName,
                            State           = newPartnerRequestModel.BillAddress != null ? newPartnerRequestModel.BillAddress.State : string.Empty,
                            FullName        = newPartnerRequestModel.PartnerName,
                        };
                        var RealmDb = Realm.GetInstance(RealmDbManager.GetRealmDbConfig());
                        await RealmDb.WriteAsync((realmDb) =>
                        {
                            realmDb.Add(partnerModel);
                        });

                        await _navigationService.GoBackAsync(new NavigationParameters
                        {
                            { "partnerModel", partnerModel }
                        }, animated : false);
                    }
                    catch (Exception ex)
                    {
                        Crashes.TrackError(ex);
                    }
                }
            }
            catch (Exception ex)
            {
                Crashes.TrackError(ex);
            }
            finally
            {
                Loader.StopLoading();
            }
        }