public List <Software> GetSoftwareGreaterThanInput(string input) { var results = new List <Software>(); //TODO: Add front-end validation and error handling for invalid inputs input = ValidateInput(input); Version.TryParse(input, out Version inputVersion); if (inputVersion != null) { var existingSoftware = SoftwareManager.GetAllSoftware(); foreach (var software in existingSoftware) { if (Version.TryParse(software.Version, out Version ver)) { if (ver > inputVersion) { results.Add(software); } } else { //TODO: handle bad versions in existingSoftware } } return(results); } return(results); //TODO: Handle bad version input }
public VersionHelper() { foreach (var software in SoftwareManager.GetAllSoftware()) { AllSoftware.Add(software); } }
public void GetAllSoftwareTest() { var allSoftware = SoftwareManager.GetAllSoftware().ToList(); // Fixed/hard-coded software manager so the data is consistent for the unit test. Assert.IsTrue(allSoftware.Count == 9); allSoftware.ForEach(o => Assert.IsFalse(string.IsNullOrWhiteSpace(o.Name))); allSoftware.ForEach(o => Assert.IsFalse(string.IsNullOrWhiteSpace(o.Version))); }
public JsonResult GreaterSoftware([FromUri] SearchRequest request) { if (!ModelState.IsValid) { return(new JsonResult(new List <Software> { new Software { Name = "Invalid", Version = "Input was not in correct format." } } )); } var inputVersion = software.GetInputVersion(request.Input); return(new JsonResult(software.GetSoftwareGreaterThan(inputVersion, SoftwareManager.GetAllSoftware()))); }
public void GetAllSoftwareFromFactoryManagerTest() { var dataManager = new SoftwareDataManagerFactory().CreateSoftwareDataManager(); var allSoftware = dataManager.GetAllSoftware().ToList(); // now get all software from static to compare var allSoftware2 = SoftwareManager.GetAllSoftware().ToList(); Assert.IsTrue(allSoftware.Count == allSoftware2.Count); allSoftware.ForEach(o => Assert.IsTrue(allSoftware2.Any(x => { return(o.Name == x.Name && o.Version == x.Version); }))); }
public void OnPost() { if (ModelState.IsValid) { try { if (!this.Version.Contains(".")) { this.Version += ".0"; // System.Version does not treat "2" as a valid version so convert to equivalent "2.0" } Version ver = new Version(this.Version); var software = SoftwareManager.GetAllSoftware(); this.Results = software.Where(s => s.VersionObj > ver).OrderBy(o => o.VersionObj).ToList(); } catch (Exception e) { ModelState.AddModelError("Version", e.Message); } } }
public IEnumerable <Software> GetSoftwareWithGreaterVersion(SemVersion version) { var softwareResult = new List <Software>(); var allSoftware = SoftwareManager.GetAllSoftware(); foreach (var software in allSoftware) { if (!SemVersion.TryParse(software.Version, out var parsedVersion)) { _logger.LogWarning($"Unable to parse version from source date.{Environment.NewLine}\tName: {software.Name};{Environment.NewLine}\tVersion: {software.Version}"); continue; } if (parsedVersion > version) { softwareResult.Add(software); } } return(softwareResult); }
public Task <IEnumerable <Software> > Handle(SearchVersionCommand request, CancellationToken cancellationToken) { try { _logger.LogTrace("Processing request '{request}' ...", request); var watch = Stopwatch.StartNew(); var matched = SoftwareManager .GetAllSoftware() .Where(software => _versionMatcher.IsGreaterThan(software.Version, request.Version)) .ToList(); watch.Stop(); _logger.LogTrace("Processed request '{requestName}': {elapsed} ms", request, watch.ElapsedMilliseconds); return(Task.FromResult <IEnumerable <Software> >(matched)); } catch (Exception ex) { _logger.LogError(ex, "Error processing request '{requestName}': {errorMessage}", request, ex.Message); throw; } }
public void OnGet() { this.Version = ""; this.Results = SoftwareManager.GetAllSoftware(); }
public IEnumerable <Software> Get() { var softwareList = SoftwareManager.GetAllSoftware(); return(softwareList); }
public IEnumerable <Software> GetAllSoftware() { return(SoftwareManager.GetAllSoftware()); }