public async Task CreateStore(Store store) { var result = await taskHelperFactory. CreateInternetAccessViewModelInstance(loggingService /*, this*/). TryExecuteAsync(() => storeApi.Create(new StoreCreateRequest() { AutoAccept = store.AutoAccept, Name = store.Name, StoreLocation = StoreLocationRequest.Parse(store.StoreLocation), })); if (result.IsSuccess) { var storeResponse = result.Value; await OnCreateStoreSuccessful(new Store() { Id = storeResponse.Id, Name = storeResponse.Name, Products = storeResponse.Products != null ? storeResponse.Products?.Select(p => ProductsResponse.Parse(p)).ToList() : new List <Product>(), AutoAccept = storeResponse.AutoAccept, Image = storeResponse.Image, StoreLocation = storeResponse.StoreLocation != null ? StoreLocationResponse.Parse(storeResponse.StoreLocation) : null, }); } }
public static Store Parse(StoreResponse response) { return(new Store() { Id = response.Id, Name = response.Name, Image = response.Image, AutoAccept = response.AutoAccept, StoreLocation = response.StoreLocation != null ? StoreLocationResponse.Parse(response.StoreLocation) : null, Products = response.Products?.Select(pr => ProductsResponse.Parse(pr)).ToList() ?? new List <Product>(), }); }