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,
            });
        }
    }
Esempio n. 2
0
    public async Task DoRegisterAsync(string email, string password, string name)
    {
        var result = await taskHelperFactory.
                     CreateInternetAccessViewModelInstance(loggingService /*, this*/).
                     TryExecuteAsync(
            () => authApi.SignUp(new Models.Requests.ClientSignUpRequest()
        {
            Email    = email,
            Name     = name,
            Password = password,
        }));

        if (result)
        {
            await RegisterSuccessesful(ClientSignUpResponse.Parse(result.Value));
        }
    }
Esempio n. 3
0
    public async Task DoLoginAsync(
        IBusyViewModel busyViewModel,
        string email,
        string pass)
    {
        var result = await taskHelperFactory.
                     CreateInternetAccessViewModelInstance(loggingService, busyViewModel).
                     TryExecuteAsync(
            () => authApi.SignIn(new Models.Requests.ShopkeeperSignInRequest()
        {
            Email    = email,
            Password = pass,
        }));

        if (result)
        {
            await LogInSuccessful(ShopkeeperSignInResponse.Parse(result.Value));
        }
    }
Esempio n. 4
0
    public async Task RegisterCommandAsync(IBusyViewModel viewModel, Shopkeeper newShopkeeper)
    {
        var result = await taskHelperFactory.
                     CreateInternetAccessViewModelInstance(loggingService, viewModel).
                     TryExecuteAsync(
            () => authApi.SignUp(new Models.Requests.ShopkeeperSignUpRequest()
        {
            Email    = newShopkeeper.Email,
            Password = newShopkeeper.Password,
            ////Name = newShopkeeper.Name,
        }));

        if (result)
        {
            await RegisterSuccessesful(new Shopkeeper()
            {
                Id    = result.Value.Id,
                Email = result.Value.Email,
                Name  = result.Value.Name,
                Token = result.Value.Token,
            });
        }
    }