コード例 #1
0
        public async Task <User> GetUser(string id)
        {
            var path = $"{_baseUri}/{id}";

            try
            {
                var userDto = await WebApiClient.GetApiResult <UserDto>(path);

                return(userDto == null ? null : _mapper.Map <User>(userDto));
            }
            catch (HttpRequestException e)
            {
                Console.WriteLine(e.Message);
                return(null);
            }
        }
コード例 #2
0
        public async Task <Company> Get(string id)
        {
            var path = $"{_baseUri}/{id}";

            try
            {
                var companyDto = await WebApiClient.GetApiResult <CompanyDto>(path);

                var company = _mapper.Map <Company>(companyDto);

                return(company);
            }
            catch (HttpRequestException e)
            {
                Console.WriteLine(e.Message);
                return(null);
            }
        }
コード例 #3
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);
            }
        }
コード例 #4
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);
            }
        }
コード例 #5
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);
            }
        }
コード例 #6
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);
            }
        }