Esempio n. 1
0
        public async Task <List <Address> > GetByUserId(string id)
        {
            var path = $"{_baseUri}/GetByUserId/{id}";

            try
            {
                var dtos = await WebApiClient.GetApiResult <List <AddressDto> >(path);

                if (dtos == null)
                {
                    return(null);
                }

                var addresses = _mapper.ProjectTo <Address>(dtos.AsQueryable());

                return(addresses.ToList());
            }
            catch (HttpRequestException e)
            {
                Console.WriteLine(e.Message);
                return(null);
            }
        }
Esempio n. 2
0
        public async Task <Driver> GetById(string id)
        {
            var path = $"{_baseUri}/{id}";

            try
            {
                var dto = await WebApiClient.GetApiResult <DriverDto>(path);

                if (dto == null)
                {
                    return(null);
                }

                var driver = _mapper.Map <Driver>(dto);

                return(driver);
            }
            catch (HttpRequestException e)
            {
                Console.WriteLine(e.Message);
                return(null);
            }
        }
Esempio n. 3
0
        public async Task <Address> GetAddress(string id)
        {
            var path = $"{_baseUri}/{id}";

            try
            {
                var dto = await WebApiClient.GetApiResult <AddressDto>(path);

                if (dto == null)
                {
                    return(null);
                }

                var address = _mapper.Map <Address>(dto);

                return(address);
            }
            catch (HttpRequestException e)
            {
                Console.WriteLine(e.Message);
                return(null);
            }
        }
Esempio n. 4
0
        public async Task <List <Driver> > Get()
        {
            var path = $"{_baseUri}";

            try
            {
                var driverDtos = await WebApiClient.GetApiResult <List <DriverDto> >(path);

                if (driverDtos == null)
                {
                    return(null);
                }

                var drivers = _mapper.ProjectTo <Driver>(driverDtos.AsQueryable()).ToList();

                return(drivers);
            }
            catch (HttpRequestException e)
            {
                Console.WriteLine(e.Message);
                return(null);
            }
        }