public IActionResult Index(int?customerID, bool?status) { var _url = this._config.VehicleDashBoardURL; var _vmethodName = this._config.CustomersVehicleMethod; var _cmethodName = this._config.CustomersLookupMethod; GlobalRestClient <CustomerLookup> cusRestClient = new GlobalRestClient <CustomerLookup>(_url); Dictionary <string, object> cusRestParam = new Dictionary <string, object>(); var cusres = cusRestClient.GetWithFilter(cusRestParam, _cmethodName).ToList(); GlobalRestClient <CustomerVehicles> restClient = new GlobalRestClient <CustomerVehicles>(_url); Dictionary <string, object> restParam = new Dictionary <string, object>(); if (customerID.HasValue) { restParam.Add("customerID", customerID.Value.ToString()); } if (status.HasValue) { restParam.Add("status", status.Value.ToString()); } var cusVehres = restClient.GetWithFilter(restParam, _vmethodName).ToList(); VehiclesCustomerLookup vcl = new VehiclesCustomerLookup(); vcl.CusLookup = cusres; vcl.CusVehicles = cusVehres; return(View(vcl)); }
public List <CustomerVehicleDTO> GetCustomersVehicles(int?customerID, bool?status) { try { List <CustomerVehicleDTO> cusVehList = new List <CustomerVehicleDTO>(); GlobalRestClient <Customer> cusrestClient = new GlobalRestClient <Customer>(_customerUrl); Dictionary <string, object> cusrestParam = new Dictionary <string, object>(); if (customerID.HasValue) { cusrestParam.Add("customerID", customerID.Value.ToString()); } var cusres = cusrestClient.GetWithFilter(cusrestParam, _customerMethodName).ToList(); GlobalRestClient <Vehicle> vehrestClient = new GlobalRestClient <Vehicle>(_vehicleUrl); List <Vehicle> vres = new List <Vehicle>(); foreach (Customer c in cusres) { Dictionary <string, object> vehrestParam = new Dictionary <string, object>(); vehrestParam.Add("customerID", c.ID.ToString()); if (status.HasValue) { vehrestParam.Add("status", status.Value.ToString()); } vres.AddRange(vehrestClient.GetWithFilter(vehrestParam, _vehicleMethodName).ToList()); } var cusVehres = from c in cusres join v in vres on c.ID equals v.CustomerId select new CustomerVehicle { ID = c.ID, Name = c.Name, Address = c.Address, VIN = v.VIN, RegNr = v.RegNr, CustomerId = v.CustomerId, LastPing = v.LastPing, Status = v.Status }; cusVehList = CustomerVehicleDTO.GetList(cusVehres.ToList()).ToList(); return(cusVehList); } catch (Exception ex) { _logger.LogCritical(ex.Message); throw ex; } }
public IActionResult Index(string vin) { var _url = this._config.VehicleDashBoardURL; var _vmethodName = this._config.CustomersVehicleMethod; GlobalRestClient <CustomerVehicles> restClient = new GlobalRestClient <CustomerVehicles>(_url); Dictionary <string, object> restParam = new Dictionary <string, object>(); var cusVehres = restClient.GetWithFilter(restParam, _vmethodName).ToList(); if (!string.IsNullOrEmpty(vin)) { GlobalRestClient <string> vrestClient = new GlobalRestClient <string>(_url); Dictionary <string, object> vrestParam = new Dictionary <string, object>(); vrestParam.Add("vin", vin); _vmethodName = this._config.UpdateVehicleStatusMethod; var res = vrestClient.Post(vrestParam, _vmethodName); } return(View(cusVehres)); }