예제 #1
0
        public ActionResult AssemblyStat(int?assemblyId)
        {
            var computerAssembly = _computerAssemblyService.GetComputerAssembly(assemblyId.Value);

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

            var model = new ComputerAssemblyStatModel();

            model.CPUFrequency = computerAssembly.CPU != null ? ((double)computerAssembly.CPU.Frequency / 1000) + " GHz" : " - ";
            model.CPUCores     = computerAssembly.CPU != null?computerAssembly.CPU.CoresNumber.ToString() : " - ";

            model.CPUThreads = computerAssembly.CPU != null?computerAssembly.CPU.ThreadsNumber.ToString() : " - ";

            model.VideoMemory          = computerAssembly.VideoCards.Count() > 0 ? CreateVideoMemoryDescription(computerAssembly.VideoCards.ElementAt(0).VideoCard.MemorySize) : " - ";
            model.VideoMemoryFrequency = computerAssembly.VideoCards.Count() > 0 ? computerAssembly.VideoCards.ElementAt(0).VideoCard.MemoryFrequency + " MHz" : " - ";
            model.VideoFrequency       = computerAssembly.VideoCards.Count() > 0 ? computerAssembly.VideoCards.ElementAt(0).VideoCard.Frequency + " MHz" : " - ";
            model.TotalRam             = computerAssembly.ComputerAssemblyRAMs.Count() > 0 ? CreateVideoMemoryDescription(_computerAssemblyService.GetTotalRAM(computerAssembly)) : " - ";
            model.TotalMemory          = (computerAssembly.SSDs.Count() > 0 || computerAssembly.HDDs.Count() > 0) ? CreateOuterMemoryDescription(_computerAssemblyService.GetTotalVolume(computerAssembly)) : " - ";
            model.TotalPrice           = _computerAssemblyService.CalculatePrice(computerAssembly);


            return(PartialView(model));
        }
예제 #2
0
        public IActionResult AssemblyTable(AssemblySearchModel searchDetails)
        {
            var computers = _computerAssemblyService.GetComputerAssemblies().Where(m => m.Public);

            if (searchDetails != null)
            {
                if (searchDetails.MinPrice.HasValue)
                {
                    computers = computers.Where(m => _computerAssemblyService.CalculatePrice(m) >= searchDetails.MinPrice);
                }
                if (searchDetails.MaxPrice.HasValue)
                {
                    computers = computers.Where(m => _computerAssemblyService.CalculatePrice(m) <= searchDetails.MaxPrice);
                }
                if (searchDetails.MinFrequency.HasValue)
                {
                    computers = computers.Where(m => m.CPU.Frequency >= searchDetails.MinFrequency);
                }
                if (searchDetails.MaxFrequency.HasValue)
                {
                    computers = computers.Where(m => m.CPU.Frequency <= searchDetails.MaxFrequency);
                }
                if (searchDetails.MinCores.HasValue)
                {
                    computers = computers.Where(m => m.CPU.CoresNumber >= searchDetails.MinCores);
                }
                if (searchDetails.MaxCores.HasValue)
                {
                    computers = computers.Where(m => m.CPU.CoresNumber <= searchDetails.MaxCores);
                }
                if (searchDetails.MinVideoMemory.HasValue)
                {
                    computers = computers.Where(m => m.VideoCards.ElementAt(0).VideoCard.MemorySize >= searchDetails.MinVideoMemory);
                }
                if (searchDetails.MaxVideoMemory.HasValue)
                {
                    computers = computers.Where(m => m.VideoCards.ElementAt(0).VideoCard.MemorySize <= searchDetails.MaxVideoMemory);
                }
                if (searchDetails.MinRAM.HasValue)
                {
                    computers = computers.Where(m => _computerAssemblyService.GetTotalRAM(m) >= searchDetails.MinRAM);
                }
                if (searchDetails.MaxRAM.HasValue)
                {
                    computers = computers.Where(m => _computerAssemblyService.GetTotalRAM(m) >= searchDetails.MaxRAM);
                }
                if (searchDetails.MinVolume.HasValue)
                {
                    computers = computers.Where(m => _computerAssemblyService.GetTotalVolume(m) >= searchDetails.MinVolume);
                }
                if (searchDetails.MaxVolume.HasValue)
                {
                    computers = computers.Where(m => _computerAssemblyService.GetTotalVolume(m) <= searchDetails.MaxVolume);
                }
            }
            var model = computers.Select(m => new ComputerAssemblyViewModel()
            {
                Id        = m.Id,
                Name      = m.Name,
                UserId    = m.OwnerId,
                OwnerName = m.Owner.Name + " " + m.Owner.Surname
            });

            model = model.Where(m => string.IsNullOrEmpty(searchDetails.Name) || m.Name.Contains(searchDetails.Name) || m.OwnerName.Contains(searchDetails.Name));

            return(PartialView(model));
        }