コード例 #1
0
        //[ValidateAntiForgeryToken]
        public ActionResult Edit(VideoCardViewModel model)
        {
            var videoCard = _videoCardService.GetVideoCard(model.Id);

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

            if (ModelState.IsValid)
            {
                videoCard.Name                  = model.Name;
                videoCard.Description           = model.Description;
                videoCard.Frequency             = model.Frequency;
                videoCard.MemoryFrequency       = model.MemoryFrequency;
                videoCard.MemorySize            = model.MemorySize;
                videoCard.MinimumPowerConsuming = model.MinimumPowerConsuming;
                videoCard.ManufacturerId        = model.ManufacturerId;
                videoCard.VideoCardInterfaceId  = model.VideoCardInterfaceId;
                videoCard.GraphicMemoryTypeId   = model.GraphicMemoryTypeId;
                videoCard.GPUId                 = model.GPUId;
                videoCard.Price                 = model.Price;


                if (model.Image != null)
                {
                    var helper = new ImageHelper(_webHostEnvironment);
                    var image  = helper.GetUploadedFile(model.Image, "VideoCard");
                    videoCard.Image = image;
                }

                var result = _videoCardService.UpdateVideoCard(videoCard);

                model.Id    = videoCard.Id;
                model.Image = null;

                if (result.Succedeed)
                {
                    return(View("../Catalog/Index", new { startView = "VideoCard" }));
                }

                return(NotFound(result));
            }
            var videoCardInterfaces = _videoCardInterfaceService.GetVideoCardInterfaces().Select(m => new VideoCardInterfaceViewModel()
            {
                Id = m.Id, Name = m.Name, Multiplier = m.Multiplier, Version = m.Version
            });

            ViewBag.VideoCardInterfaces = new SelectList(videoCardInterfaces, "Id", "FullName");
            var gpus = _gpuService.GetGPUs();

            ViewBag.GPUs = new SelectList(gpus, "Id", "Name");
            var graphicMemoryTypes = _graphicMemoryTypeService.GetGraphicMemoryTypes();

            ViewBag.GraphicMemoryTypes = new SelectList(graphicMemoryTypes, "Id", "Name");
            var manufacturers = _manufacturerService.GetManufacturers();

            ViewBag.Manufacturers = new SelectList(manufacturers, "Id", "Name");
            return(View("Edit", model));
        }
コード例 #2
0
        public ActionResult Edit(int id)
        {
            var videoCard = _videoCardService.GetVideoCard(id);

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

            var model = new VideoCardViewModel()
            {
                Id                           = videoCard.Id,
                Name                         = videoCard.Name,
                Description                  = videoCard.Description,
                Frequency                    = videoCard.Frequency,
                FrequencyDisplay             = (videoCard.Frequency) + " MHz",
                MemorySize                   = videoCard.MemorySize,
                MemorySizeDisplay            = CreateMemoryDescription(videoCard.MemorySize),
                MinimumPowerConsumingDisplay = videoCard.MinimumPowerConsuming + " Вт",
                MinimumPowerConsuming        = videoCard.MinimumPowerConsuming,
                MemoryFrequency              = videoCard.MemoryFrequency,
                ManufacturerId               = videoCard.ManufacturerId,
                Manufacturer                 = videoCard.Manufacturer.Name,
                VideoCardInterfaceId         = videoCard.VideoCardInterfaceId,
                VideoCardInterface           = (new VideoCardInterfaceViewModel()
                {
                    Name = videoCard.VideoCardInterface.Name, Multiplier = videoCard.VideoCardInterface.Multiplier, Version = videoCard.VideoCardInterface.Version
                }).FullName,
                GraphicMemoryTypeId          = videoCard.GraphicMemoryTypeId,
                GraphicMemoryType            = videoCard.GraphicMemoryType.Name,
                GPUId                        = videoCard.GPUId,
                GPU                          = videoCard.GPU.Name,
                ImagePath                    = "/Images/VideoCard/" + videoCard.Image,
                Price                        = videoCard.Price
            };

            var videoCardInterfaces = _videoCardInterfaceService.GetVideoCardInterfaces().Select(m => new VideoCardInterfaceViewModel()
            {
                Id = m.Id, Name = m.Name, Multiplier = m.Multiplier, Version = m.Version
            });

            ViewBag.VideoCardInterfaces = new SelectList(videoCardInterfaces, "Id", "FullName");
            var gpus = _gpuService.GetGPUs();

            ViewBag.GPUs = new SelectList(gpus, "Id", "Name");
            var graphicMemoryTypes = _graphicMemoryTypeService.GetGraphicMemoryTypes();

            ViewBag.GraphicMemoryTypes = new SelectList(graphicMemoryTypes, "Id", "Name");
            var manufacturers = _manufacturerService.GetManufacturers();

            ViewBag.Manufacturers = new SelectList(manufacturers, "Id", "Name");
            return(View("Edit", model));
        }
コード例 #3
0
        public ActionResult PartialDetails(int id)
        {
            var videoCard = _videoCardService.GetVideoCard(id);

            if (videoCard == null)
            {
                return(NotFound());
            }
            var model = new VideoCardViewModel()
            {
                Id                           = videoCard.Id,
                Name                         = videoCard.Name,
                Description                  = videoCard.Description,
                Frequency                    = videoCard.Frequency,
                FrequencyDisplay             = (videoCard.Frequency) + " MHz",
                MemoryFrequencyDisplay       = videoCard.MemoryFrequency + " MHz",
                MemorySize                   = videoCard.MemorySize,
                MemorySizeDisplay            = CreateMemoryDescription(videoCard.MemorySize),
                MinimumPowerConsumingDisplay = videoCard.MinimumPowerConsuming + " Вт",
                ManufacturerId               = videoCard.ManufacturerId,
                Manufacturer                 = videoCard.Manufacturer.Name,
                VideoCardInterfaceId         = videoCard.VideoCardInterfaceId,
                VideoCardInterface           = (new VideoCardInterfaceViewModel()
                {
                    Name = videoCard.VideoCardInterface.Name, Multiplier = videoCard.VideoCardInterface.Multiplier, Version = videoCard.VideoCardInterface.Version
                }).FullName,
                GraphicMemoryTypeId          = videoCard.GraphicMemoryTypeId,
                GraphicMemoryType            = videoCard.GraphicMemoryType.Name,
                GPUId                        = videoCard.GPUId,
                GPU                          = videoCard.GPU.Name,
                ImagePath                    = "/Images/VideoCard/" + videoCard.Image,
                Price                        = videoCard.Price
            };

            return(PartialView("PartialDetails", model));
        }