예제 #1
0
        public IActionResult EvaluateResult(int id, int assemblyId)
        {
            var computerAssembly = _computerAssemblyService.GetComputerAssembly(assemblyId);

            if (computerAssembly == null)
            {
                return(NotFound());
            }
            var userId = _userService.GetApplicationUserManager().GetUserId(this.User);

            if (computerAssembly.OwnerId != userId)
            {
                return(Forbid());
            }
            var software = _softwareService.GetSoftware(id);

            if (software == null)
            {
                return(NotFound());
            }

            var result = _computerAssemblyService.SoftwareSyncEvaluate(id, computerAssembly);

            if (!result.Succedeed)
            {
                return(Json(result));
            }

            var model = new SoftwareResultViewModel();

            model.ComputerAssembly = computerAssembly;
            model.Software         = new SoftwareViewModel()
            {
                Id               = software.Id,
                Name             = software.Name,
                ShortDescription = string.IsNullOrEmpty(software.Description) ? "" : CreateShortDescription(software.Description),
                Publisher        = software.Publisher.Name,
                Developer        = software.Developer.Name,
                RecomendedCPURequirmentsDisplay       = CreateCPuDisplay(software.SoftwareCPURequirements.Where(m => m.RequirementTypeId == 2).ToList()),
                RecomendedVideoCardRequirmentsDisplay = CreateVideoCardDisplay(software.SoftwareVideoCardRequirements.Where(m => m.RequirementTypeId == 2).ToList()),
                MinimiumRequiredRAMDisplay            = software.MinimiumRequiredRAM + " Гб",
                RecommendedRequiredRAMDisplay         = software.RecommendedRequiredRAM + " Гб",
                DiscVolumeDisplay                  = CreateMemoryDescription(software.DiscVolume),
                MinimumCPURequirmentsDisplay       = CreateCPuDisplay(software.SoftwareCPURequirements.Where(m => m.RequirementTypeId == 1).ToList()),
                MinimumVideoCardRequirmentsDisplay = CreateVideoCardDisplay(software.SoftwareVideoCardRequirements.Where(m => m.RequirementTypeId == 1).ToList()),
                ImagePath   = "/Images/Software/" + software.Image,
                Price       = software.Price,
                Description = software.Description
            };
            model.Result = result;

            return(PartialView(model));
        }