private void AddProductAction() { ThreadingHelpers.InvokeOnMainThread(async() => { // AppInitialiserService.SetInitialiser<AddProductPageViewModel>((AddProductPageViewModel vm) => // { // vm.UserDetails = UserDetails; // vm.ProductList = Products; // vm.Product = new Product(); // vm.ProductTypes = App.MasterData.ProductTypeMaster; // vm.IsAddProduct = true; // }); await AppNavigationService.GoBackAsync(); }); }
public async Task EditProductAction(Product item) { AppSpinner.ShowLoading(); await Task.Delay(10); ThreadingHelpers.InvokeOnMainThread(async() => { // AppInitialiserService.SetInitialiser<AddProductPageViewModel>((AddProductPageViewModel vm) => // { // vm.UserDetails = UserDetails; // vm.ProductList = Products; // vm.Product = item; // vm.IsAddProduct = false; // }); await AppNavigationService.GoBackAsync(); } ); AppSpinner.HideLoading(); }
protected virtual async Task GoBack() { await AppNavigationService.GoBackAsync(); }
private async Task NextButtonTapped() { try { if (!await ValidateFields()) { return; } //if (!IsOrgVisible) //{ // UserDetails.Organization = string.Empty; //} //switch (LinCAppUserType) //{ // case LinCUserType.Consumer: // UserDetails.Organization = string.Empty; // UserDetails.RegisterType = string.Empty; // break; // default: // break; //} AppSpinner.ShowLoading(); if (ShouldUseCurrentLocation) { var status = await CheckPermission(Permission.Location); if (status == PermissionStatus.Granted) { var location = await GetUserLocation(); if (location != null) { UserDetails.Latitude = location.Latitude; UserDetails.Longitude = location.Longitude; var placemark = await GetUserAddressFromLatLong(location.Latitude, location.Longitude); if (placemark != null) { UserDetails.Pin = string.IsNullOrEmpty(placemark.PostalCode) ? 0 : int.Parse(placemark.PostalCode); UserDetails.AddressLine1 = $"{placemark.FeatureName}, {placemark.SubLocality}, {placemark.Locality}"; UserDetails.AddressLine2 = string.Empty; UserDetails.CountryId = CountryMasterData.Where(l => l.CountryCode.Equals(placemark.CountryCode)).FirstOrDefault().CountryId; UserDetails.StateId = StateMasterData.Where(l => l.StateName.Contains(placemark.AdminArea)).FirstOrDefault().StateId; } } } } else { string countryName = CountryMasterData.Where(l => l.CountryId.Equals(UserDetails.CountryId)).FirstOrDefault()?.CountryName; string stateCode = StateMasterData.Where(l => l.StateId.Equals(UserDetails.StateId)).FirstOrDefault()?.StateCode; string address = $"{UserDetails.AddressLine1} {UserDetails.AddressLine2} {stateCode} {countryName}"; // get location from address var location = await GetUserLocationFromAddress(address); if (location != null) { UserDetails.Latitude = location.Latitude; UserDetails.Longitude = location.Longitude; //var placemark = await GetUserAddressFromLatLong(location.Latitude, location.Longitude); } } if (!UserDetails.UserTypeId.Equals(2)) { if (UserDetails.ProductTypeIds.Count > 0) { UserDetails.ProductTypeIds = UserDetails.ProductTypeIds; } } else { UserDetails.ProductTypeIds = null; } // Create User //string userTypeId = UserDetails.UserTypeId; //remove later UserDetails.UserId = null; var response = await _services.UserService.CreateUserAsync(null, null, UserDetails); //response.ServiceErrorCode = LinCTrasactionStatus.Success.ToString(); // remove later if (response.ServiceErrorCode.Equals(LinCTrasactionStatus.Success.ToString())) { ThreadingHelpers.InvokeOnMainThread(async() => await AppNavigationService.GoBackAsync()); /*UserDetails = response.Data; * App.UserDetails = UserDetails; * * // get product category list * var responsePrdCategory = await _services.UserService.GetProductCategoryByUser(UserDetails.UserId.Value); * * if(responsePrdCategory.ServiceErrorCode.Equals(LinCTrasactionStatus.Success.ToString())) * { * App.MasterData.ProductCategoryList = responsePrdCategory.Data.ProductCategoryList; * * ThreadingHelpers.InvokeOnMainThread(async () => * await AppNavigationService.GoToAsync(nameof(AddProductPage).ToLower(), * (AddProductPageViewModel vm) => * { * vm.UserDetails = UserDetails; * vm.IsAddProduct = true; * vm.ProductTypes = App.MasterData.ProductTypeMaster; * }) * ); * } * else * { * AppErrorService.AddError(response); * }*/ } else { AppErrorService.AddError(response); } AppSpinner.HideLoading(); AppErrorService.ProcessErrors(); } catch (Exception ex) { HandleUIError(ex); } }