예제 #1
0
        public async Task <IActionResult> Edit(int id, [Bind("ID,AvarTagNumber,Brand,CPUFrequency,CPUType,Cost,HDDSize,LANMAC,LaptopScreenSize,MachineName,MemorySize,ModelNo,ModelSeries,Note,OEMLicense,OEMOperatingSystem,OfficeLocation,OrderNo,PurchaseDate,Retired,SerialNumber,UpgradeLicense,UpgradedTo,User,WLANMAC,Warranty")] ComputerCase computerCase)
        {
            if (id != computerCase.ID)
            {
                return(NotFound());
            }
            var usersList = this._context.ComputerCases.Select(x => x.User).Distinct();

            ViewBag.usersList = usersList.Select(x =>
                                                 new SelectListItem()
            {
                Text = x.ToString()
            });
            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(computerCase);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ComputerCaseExists(computerCase.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(Redirect("~/ComputerCases/Index?#page"));
            }
            return(Redirect("~/ComputerCases/Edit/" + computerCase.ID + "?#page"));
        }
예제 #2
0
 public ActionResult ChangeComputerCase(ComputerCase p, HttpPostedFileBase NewImage, bool IsDeletePreviousImageFromServer = false, int page = 1, int pageSize = 20)
 {
     ViewBag.page     = page;
     ViewBag.pageSize = pageSize;
     if (ModelState.IsValid)
     {
         if (NewImage != null)
         {
             if (NewImage.ContentLength <= 200000)
             {
                 AddOrAddRemoveImageForCatalog(NewImage, IsDeletePreviousImageFromServer, p);
             }
             else
             {
                 ModelState.AddModelError("NewImage", "Изображение должно быть меньше 200 Кб");
                 return(View(pcComponentsUnit.ComputerСases.GetElement(p.ID)));
             }
         }
         p.FullName = string.Format($"{p.Category} {p.Model} {p.FormFactor} ({p.ID})");
         pcComponentsUnit.ComputerСases.Update(p);
         pcComponentsUnit.Save();
         return(RedirectToActionPermanent("ComponentsCatalog", "Catalog", new { category = p.Category, page, pageSize }));
     }
     return(View(pcComponentsUnit.ComputerСases.GetElement(p.ID)));
 }
예제 #3
0
        public async Task <IActionResult> Create([Bind("ID,AvarTagNumber,Brand,CPUFrequency,CPUType,Cost,HDDSize,LANMAC,LaptopScreenSize,MachineName,MemorySize,ModelNo,ModelSeries,Note,OEMLicense,OEMOperatingSystem,OfficeLocation,OrderNo,PurchaseDate,Retired,SerialNumber,UpgradeLicense,UpgradedTo,User,WLANMAC,Warranty")] ComputerCase computerCase)
        {
            if (ModelState.IsValid)
            {
                _context.Add(computerCase);
                await _context.SaveChangesAsync();

                return(Redirect("~/ComputerCases/Create?#page"));
            }
            return(Redirect("~/ComputerCases/Create?#page"));
        }
예제 #4
0
        public async Task <IActionResult> Create([Bind("ID,AvarTagNumber,BrandId,CPUFrequency,CPUType,Cost,EmployeeId,HDDSize,LANMAC,LaptopScreenSize,MachineName,MemorySize,ModelNo,ModelSeries,Note,OEMLicense,OEMOperatingSystem,OfficeLocation,OrderNo,PurchaseDate,Retired,SerialNumber,UpgradeLicense,UpgradedTo,WLANMAC,Warranty")] ComputerCase computerCase)
        {
            if (ModelState.IsValid)
            {
                _context.Add(computerCase);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            ViewData["BrandId"]    = new SelectList(_context.Brands, "BrandId", "BrandName", computerCase.BrandId);
            ViewData["EmployeeId"] = new SelectList(_context.Employees, "EmployeeID", "EmployeeName", computerCase.EmployeeId);
            return(View(computerCase));
        }
예제 #5
0
    public Computer build()
    {
        Computer pc = new Computer();

        ComputerCase pc_case       = new ComputerCase("NZXT");
        HDD          hard_drive    = new HDD("1TB");
        Fans         silent_fan    = new Fans(1000);
        CPU          cpu           = new CPU("Intel Pentium");
        GPU          graphics_card = new GPU("GT1030");

        pc.component.Add(pc_case);
        pc.component.Add(hard_drive);
        pc.component.Add(silent_fan);
        pc.component.Add(cpu);
        pc.component.Add(graphics_card);

        return(pc);
    }
예제 #6
0
 public ActionResult ChangeComputerCase(ComputerCase p)
 {
     return(View(pcComponentsUnit.ComputerСases.GetElement(p.ID)));
 }