public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { base.OnCreateView(inflater, container, savedInstanceState); this.FragmentView = this.BindingInflate(Resource.Layout.fragment_units_allocation_complete, container, false); ManageStockPostApiResponse response = this.GetArgument <ManageStockPostApiResponse>(AllocatedProductResponseKey); this.ManageStockViewModel.ProcessApiResponse(response); BindableProgressDialog progressDialog = new BindableProgressDialog(this.Activity); var set = this.CreateBindingSet <FragmentManageStockComplete, ManageStockViewModel>(); set.Bind(progressDialog).For(target => target.Visible).To(source => source.IsBusy); set.Bind(progressDialog).For(target => target.Message).To(source => source.ProgressDialogMessage); set.Apply(); this.ManageStockViewModel.NextButtonVisible = false; this.ManageStockViewModel.PreviousButtonVisible = false; this.ManageStockViewModel.NegativeButtonText = this.GetString(Resource.String.home); // App trackking GoogleAnalyticService.Instance.TrackScreen("Manage Stock Complete"); return(this.FragmentView); }
private void ShowlastFragment(ManageStockPostApiResponse res) { FragmentTransaction ft = FragmentManager.BeginTransaction(); MvxFragmentBase fragment = new FragmentManageStockComplete(); fragment.SetArgument(FragmentManageStockComplete.AllocatedProductResponseKey, res); ft.Replace(Resource.Id.main_content, fragment, ManageStockView.MainContentFragmentTag); ft.Commit(); }
private async Task <ManageStockPostApiResponse> ReturnAllocateSuccess() { var response = new ManageStockPostApiResponse { Success = true, Text = "Allocation successfull" }; return(await Task.Run(() => response)); }
public void TestProcessApiResponseFailure() { var mockResponse = new ManageStockPostApiResponse { Success = false, Text = "Allocation Failed." }; this._viewModel.ProcessApiResponse(mockResponse); Assert.That(this._viewModel.ApiStatusMessage, Is.EqualTo(mockResponse.Text)); Assert.That(this._viewModel.ApiSuccess, Is.EqualTo(mockResponse.Success)); Assert.That(this._viewModel.PositiveButtonText, Is.EqualTo(this._deviceResource.TryAgain)); Assert.That(this._viewModel.StatusIcon, Is.EqualTo(this._deviceResource.ErrorNewIcon)); }
public void TestProcessApiResponseSuccess() { var mockResponse = new ManageStockPostApiResponse { Success = true, Text = "Allocation Successfull." }; this._viewModel.ProcessApiResponse(mockResponse); Assert.That(this._viewModel.ApiStatusMessage, Is.EqualTo(mockResponse.Text)); Assert.That(this._viewModel.ApiSuccess, Is.EqualTo(mockResponse.Success)); Assert.That(this._viewModel.PositiveButtonText, Is.EqualTo(this._deviceResource.ManageStock)); Assert.IsEmpty(this._viewModel.ApiStatusDescription); Assert.That(this._viewModel.StatusIcon, Is.EqualTo(this._deviceResource.CheckMarkIcon)); }
public async Task <ManageStockPostApiResponse> ReceiveStock() { this.ProgressDialogMessage = this._deviceResource.PleaseWait; this.IsBusy = true; ReturnedProduct product = new ReturnedProduct { DsrPhone = this.DsrPhoneNumber, PersonId = this.DsrStock.PersonId, PersonRoleId = this.DsrStock.PersonRoleId }; product.Reason = this.SelectedReason.Reason; List <List <DeviceAllocationItem> > groupedSelectedList = this.SelectedUnits.GroupBy(u => u.ProductTypeId).Select(grp => grp.ToList()).ToList(); List <ScmStock> returnObj = new List <ScmStock>(); foreach (List <DeviceAllocationItem> products in groupedSelectedList) { ScmStock stock = new ScmStock(); stock.ProductTypeId = products[0].ProductTypeId; stock.Name = products[0].HeaderText; List <string> units = new List <string>(); foreach (var item in products) { units.Add(item.SerialNumber); } stock.SerialNumbers = units; returnObj.Add(stock); } product.Units = returnObj; ManageStockPostApiResponse response = await this.DsrStockAllocationService.ReceiveStockFromDsr(product); this.IsBusy = false; if (response == null) { return(new ManageStockPostApiResponse { Success = false, Text = "Units could not be returned." }); } return(response); }
public void ProcessApiResponse(ManageStockPostApiResponse response) { this.ApiStatusMessage = response.Text; this.ApiSuccess = response.Success; if (this.ApiSuccess || this._retryCount >= 3) { int statusIcon = response.Success ? this._deviceResource.CheckMarkIcon : this._deviceResource.ErrorNewIcon; this.PositiveButtonText = this._deviceResource.ManageStock; this.ApiStatusDescription = string.Empty; this.StatusIcon = statusIcon; } else { this.PositiveButtonText = this._deviceResource.TryAgain; this.StatusIcon = this._deviceResource.ErrorNewIcon; } this.ApiStatusDescription = !this._connectivityService.HasConnection() ? this._deviceResource.CheckInternetConnection : string.Empty; }
public async Task <ManageStockPostApiResponse> AllocateSelectedUnits() { this.ProgressDialogMessage = this._deviceResource.PleaseWait; this.IsBusy = true; SelectedProduct product = new SelectedProduct { DsrPhone = this.DsrPhoneNumber, PersonId = this.DsrStock.PersonId, PersonRoleId = this.DsrStock.PersonRoleId }; List <string> units = new List <string>(); foreach (var unit in this.SelectedUnits) { units.Add(unit.SerialNumber); } ScmStock scmStock = new ScmStock { ProductTypeId = this.SelectedProduct.ProductTypeId, SerialNumbers = units }; product.Units = new List <ScmStock> { scmStock }; ManageStockPostApiResponse response = await this.DsrStockAllocationService.AllocateUnitsToDsr(product); this.IsBusy = false; if (response == null) { return(new ManageStockPostApiResponse { Success = false, Text = this._deviceResource.UnitsCouldNotBeAllocated }); } return(response); }
private async Task <ManageStockPostApiResponse> ReturnAllocateReturnsNull() { ManageStockPostApiResponse response = null; return(await Task.Run(() => response)); }
private async Task AlocateSelectedUnits() { ManageStockPostApiResponse response = await this.ManageStockViewModel.AllocateSelectedUnits(); this.ShowlastFragment(response); }
private async Task ReceiveStock() { ManageStockPostApiResponse response = await this.ManageStockViewModel.ReceiveStock(); this.ShowlastFragment(response); }