Пример #1
0
        internal async Task <bool> GetCompanies(int driverId)
        {
            string urlCompany = GetBaseUrl() + Constants.REST_URL_GETCOMPANYDETAILS;
            var    companyGet = new HttpRequestMessage(HttpMethod.Get, urlCompany);

            companyGet.Headers.Add("DriverId", driverId.ToString());

            HttpResponseMessage companyResponse;

            using (HttpClient client = new HttpClient())
            {
                client.DefaultRequestHeaders.Add("Authorization", accessToken);
                try
                {
                    companyResponse = await client.SendAsync(companyGet);
                }
                catch
                {
                    return(false);
                }
            }

            if (companyResponse.IsSuccessStatusCode)
            {
                LoginCompanyResponse companyDetails = JsonConvert.DeserializeObject <LoginCompanyResponse>(companyResponse.Content.ReadAsStringAsync().Result);

                if (companyDetails.Success)
                {
                    foreach (CompanyResultResponseModel companyItem in companyDetails.Companies)
                    {
                        CompanyTable company = new CompanyTable()
                        {
                            Name     = companyItem.Name,
                            Address1 = companyItem.Address1,
                            Address2 = companyItem.Address2,
                            Address3 = companyItem.Address3,
                            PostCode = companyItem.PostCode,
                            Suburb   = companyItem.Suburb,
                            City     = companyItem.City,
                            Country  = companyItem.Country,
                            ServerId = companyItem.Id,
                            DriverId = driverId
                        };

                        if (!db.InsertUserCompany(company))
                        {
                            return(false);
                        }
                    }

                    return(true);
                }
            }

            return(false);
        }
Пример #2
0
        public CompanyTable GetCompany(int id)
        {
            List <CompanyTable> listOfCompanies = new List <CompanyTable>();

            listOfCompanies = dbService.GetCompanies(id);

            if (listOfCompanies.Count != 1)
            {
                return(null);
            }

            CompanyTable companyDetails = new CompanyTable();

            companyDetails = listOfCompanies[0];

            return(companyDetails);
        }
Пример #3
0
        internal void UpdatePage(int selectedVehicle)
        {
            VehicleTable vehicle = new VehicleTable();

            vehicle = listOfVehicles[selectedVehicle];

            CompanyTable companyDetails = new CompanyTable();

            companyDetails = GetCompany(vehicle.CompanyId);

            RegistrationEntry = vehicle.Registration;
            MakeModelEntry    = vehicle.MakeModel;
            FleetEntry        = vehicle.FleetNumber;
            Company           = companyDetails.Name;

            VehicleSelected = true;

            OnPropertyChanged("RegistrationEntry");
            OnPropertyChanged("MakeModelEntry");
            OnPropertyChanged("FleetEntry");
            OnPropertyChanged("VehicleActive");
            OnPropertyChanged("VehicleSelected");
            OnPropertyChanged("SwitchText");
        }