public LicenseModel GetById([FromBody] LicenseInput licenseInput) { if (string.IsNullOrEmpty(licenseInput?.IdentityNumber) || string.IsNullOrEmpty(licenseInput.ApplicationHash) || string.IsNullOrEmpty(licenseInput.LicenseNumber)) { throw new Exception("invalid data"); } var resp = new LicenseModel(); try { var res = _licenseRepository.GetByNumber(licenseInput.LicenseNumber, licenseInput.IdentityNumber, licenseInput.ApplicationHash); if (res != null) { resp = new LicenseModel { Expiration = res.Expiration, IsActive = res.IsActive, AssignedVersion = res.AssignedVersion, Description = "License active" }; } else { resp = new LicenseModel { IsActive = false, Description = "No active license" }; } } catch (Exception ex) { resp.Description = $"Error: {ex.Message}"; } //SetLogs new LogsClass(new Logs { Description = resp.Description, Date = DateTime.Now, LicenseNumber = licenseInput.LicenseNumber }).SetLogs(); return(resp); }
public LicenseModel GetLicense(string licenseInputLicenseNumber, string licenseInputIdentityNumber, string licenseInputApplicationHash) { var getLicense = _licenseRepository.GetByNumber(licenseInputLicenseNumber, licenseInputIdentityNumber, licenseInputApplicationHash); if (getLicense != null) { return(new LicenseModel { Expiration = getLicense.Expiration, IsActive = getLicense.IsActive, AssignedVersion = getLicense.AssignedVersion, Description = "License active" }); } return(new LicenseModel()); }