public GetAllLicenceByCompanyId ( int company_id, string status = "" ) : IEnumerable |
||
company_id | int | |
status | string | |
Résultat | IEnumerable |
public ActionResult GetCompanyByIDForJson(int id, [DefaultValue(0)] int licID, [DefaultValue(0)] int devID, string identifier, string lang, string status) { var companyController = new CompanyController(); var licenceController = new LicenceController(); var deviceController = new DeviceController(); var identifierController = new DeviceIdentifierController(); var licencestatus = status; var data = new CompanyDetail(); data.licenceList = new List <LicenceDetail>(); //1. Get Company var company = new Company(); company = companyController.GetCompanyById(id, status); if (company != null && company.company_id > 0) { data.company_id = company.company_id; data.company_name = company.company_name; data.company_address = UtilityHelper.BuildAddress(company); var licenceList = new List <Licence>(); if (devID > 0) { //2.Get Device. var device = deviceController.GetDeviceById(devID); var deviceDetail = new DeviceDetail(); //var archivedDeviceDetails = new DeviceDetail(); deviceDetail.device = device; deviceDetail.deviceIdentifierList = new List <DeviceIdentifier>(); var identifierList = new List <DeviceIdentifier>(); //3. Get DeviceIdentifier if (licID > 0) { identifierList = identifierController.GetAllDeviceIdentifier(licencestatus, "", licID, device.device_id).ToList(); } else { identifierList = identifierController.GetAllDeviceIdentifier(licencestatus, "", 0, device.device_id).ToList(); } if (identifierList != null && identifierList.Count > 0) { if (string.IsNullOrWhiteSpace(identifier.Trim())) { deviceDetail.deviceIdentifierList = identifierList; } else { deviceDetail.deviceIdentifierList = identifierList.Where(s => s.device_identifier == identifier).ToList(); } } //4. Get Licence var licenceDetail = new LicenceDetail(); var archivedLicenceDetail = new LicenceDetail(); if (licencestatus == "active") { if (licID > 0) { licenceDetail.licence = licenceController.GetLicenceById(licID, "active"); } else { licenceDetail.licence = licenceController.GetLicenceById(device.original_licence_no, "active"); } licenceDetail.deviceList = new List <DeviceDetail>(); licenceDetail.deviceList.Add(deviceDetail); data.licenceList.Add(licenceDetail); } else { if (licID > 0) { archivedLicenceDetail.licence = licenceController.GetLicenceById(licID, "archived"); } else { archivedLicenceDetail.licence = licenceController.GetLicenceById(device.original_licence_no, "archived"); } archivedLicenceDetail.deviceList = new List <DeviceDetail>(); archivedLicenceDetail.deviceList.Add(deviceDetail); //5. Add all the list to Company(data). data.licenceList.Add(archivedLicenceDetail); } } else { if (licencestatus == "active") { if (licID == 0) { licenceList = licenceController.GetAllLicenceByCompanyId(company.company_id, "active").ToList(); } else { licenceList.Add(licenceController.GetLicenceById(licID, "active")); } } else { if (licID == 0) { licenceList = licenceController.GetAllLicenceByCompanyId(company.company_id, "archived").ToList(); } else { licenceList.Add(licenceController.GetLicenceById(licID, "archived")); } } if (licenceList != null && licenceList.Count > 0) { //2. Get Licence foreach (var licence in licenceList) { var licenceDetail = new LicenceDetail(); licenceDetail.licence = licence; licenceDetail.deviceList = new List <DeviceDetail>(); //3. Get Device //var deviceList = deviceController.GetAllDevice("", "", licence.original_licence_no).ToList(); var deviceList = new List <Device>(); deviceList = deviceController.GetAllDevice(licencestatus, "", licence.original_licence_no).ToList(); if (deviceList != null && deviceList.Count > 0) { foreach (var device in deviceList) { var deviceDetail = new DeviceDetail(); deviceDetail.device = device; deviceDetail.deviceIdentifierList = new List <DeviceIdentifier>(); var identifierList = new List <DeviceIdentifier>(); //4. Get DeviceIdentifier. //if (licID > 0) //{ identifierList = identifierController.GetAllDeviceIdentifier(licencestatus, "", licID, device.device_id).ToList(); //} //else //{ // identifierList = identifierController.GetAllDeviceIdentifier(licencestatus, "", 0, device.device_id).ToList(); //} if (identifierList != null && identifierList.Count > 0) { deviceDetail.deviceIdentifierList = identifierList; } licenceDetail.deviceList.Add(deviceDetail); } } //5. Add all the list to Company(data) data.licenceList.Add(licenceDetail); } } } } var jsonResult = Json(new { data }, JsonRequestBehavior.AllowGet); jsonResult.MaxJsonLength = int.MaxValue; return(jsonResult); }
public ActionResult GetCompanyByIDForJson(int id,string lang) { var companyController = new CompanyController(); var licenceController = new LicenceController(); var deviceController = new DeviceController(); var data = new CompanyDetail(); data.licenceList = new List<Licence>(); var licenceDetail = new LicenceDetail(); var company = new Company(); var deviceList = new List<Device>(); company = companyController.GetCompanyById(id, lang); if (company != null && company.company_id > 0) { var address = new StringBuilder(); data.company_id = company.company_id; data.company_name = company.company_name; address.AppendFormat(company.addr_line_1).Append(" "); address.Append(company.addr_line_2).Append(" "); address.Append(company.addr_line_3).Append(","); address.Append(company.city).Append(","); address.Append(company.region_cd).Append(","); address.Append(company.country_cd).Append(","); address.Append(company.postal_code); data.company_address = address.ToString(); data.licenceList = licenceController.GetAllLicenceByCompanyId(company.company_id, "active").ToList(); if (data.licenceList != null && data.licenceList.Count > 0) { //Get Device foreach (var licence in data.licenceList) { licence.deviceList = new List<Device>(); //Get Device deviceList = deviceController.GetAllDevice("", "", licence.original_licence_no).ToList(); if (deviceList != null && deviceList.Count > 0) { licence.deviceList = deviceList; } } } } return Json(new { data }, JsonRequestBehavior.AllowGet); }