Beispiel #1
0
        public ActionResult GetVersionSpecific(
            [FromRoute(Name = "branch")] Branch updateBranch,
            [FromRoute(Name = "os")] OperatingSystem operatingSystem,
            [FromRoute(Name = "version")] string urlVersion)
        {
            // Grab the update.
            var update = _database.UpdateEntities
                         .Include(x => x.UpdateFiles)
                         .FirstOrDefault(x => x.Version.Equals(urlVersion) &&
                                         x.Branch == updateBranch &&
                                         x.UpdateFiles.Any(u => u.OperatingSystem == operatingSystem));

            return(GetResponse(update, operatingSystem));
        }
Beispiel #2
0
        public ActionResult GetVersionResult(
            [FromRoute(Name = "branch")] Branch updateBranch,
            [FromRoute(Name = "os")] OperatingSystem operatingSystem)
        {
            // Grab the update.
            var update = _database.UpdateEntities
                         .Include(x => x.UpdateFiles)
                         .Where(x =>
                                x.Branch == updateBranch &&
                                x.UpdateFiles.Any(u => u.OperatingSystem == operatingSystem))
                         .OrderByDescending(x => x.ReleaseDate)
                         .FirstOrDefault();

            return(GetResponse(update, operatingSystem));
        }
Beispiel #3
0
        private ActionResult GetResponse(UpdateEntity update, OperatingSystem operatingSystem)
        {
            // Check if the version was found.
            if (update == null)
            {
                return(NotFound(new
                {
                    ErrorMessage = "Version not found."
                }));
            }

            // Check if update file is present
            var updateFile = update.UpdateFiles.FirstOrDefault(u => u.OperatingSystem == operatingSystem);

            if (updateFile == null)
            {
                return(NotFound(new
                {
                    ErrorMessage = "Version download url not found."
                }));
            }

            return(Redirect(updateFile.Url));
        }