Exemplo n.º 1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,CoreNumber,Clock,MemorySize,MemorySpeed,Price,InterfaceId")] Gpu gpu)
        {
            if (id != gpu.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(gpu);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!GpuExists(gpu.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["InterfaceId"] = new SelectList(_context.Gpuinterfaces, "Id", "Id", gpu.InterfaceId);
            return(View(gpu));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name")] Ramtype ramtype)
        {
            if (id != ramtype.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(ramtype);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!RamtypeExists(ramtype.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(ramtype));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Manufacturer,Power,Width,Height,Thickness,Price")] PowerSupply powerSupply)
        {
            if (id != powerSupply.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(powerSupply);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PowerSupplyExists(powerSupply.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(powerSupply));
        }
Exemplo n.º 4
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Weight,Tdp,Price")] Cooler cooler)
        {
            if (id != cooler.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(cooler);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CoolerExists(cooler.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(cooler));
        }
Exemplo n.º 5
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Size,TypeId,Manufacturer,Speed,Price")] Ram ram)
        {
            if (id != ram.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(ram);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!RamExists(ram.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["TypeId"] = new SelectList(_context.Ramtypes, "Id", "Name", ram.TypeId);
            return(View(ram));
        }
Exemplo n.º 6
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,CoresNumber,ThreadsNumber,Clock,Manufacturer,Price,SocketId")] Cpu cpu)
        {
            if (id != cpu.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(cpu);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CpuExists(cpu.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["SocketId"] = new SelectList(_context.Sockets, "Id", "Name", cpu.SocketId);
            return(View(cpu));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,GpuinterfaceId,SocketId,Formfactor,RamtypeId,Ramcount,Usbcount,Price")] Motherboard motherboard)
        {
            if (id != motherboard.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(motherboard);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!MotherboardExists(motherboard.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["GpuinterfaceId"] = new SelectList(_context.Gpuinterfaces, "Id", "Id", motherboard.GpuinterfaceId);
            ViewData["RamtypeId"]      = new SelectList(_context.Ramtypes, "Id", "Name", motherboard.RamtypeId);
            ViewData["SocketId"]       = new SelectList(_context.Sockets, "Id", "Name", motherboard.SocketId);
            return(View(motherboard));
        }
Exemplo n.º 8
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Size,ReadSpeed,WriteSpeed,Interface,Width,Height,Thickness,Manufacturer,Price")] Drive drive)
        {
            if (id != drive.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(drive);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!DriveExists(drive.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(drive));
        }
        void replaceListInDB <T>(ICollection <T> listToInsert, ICollection <T> listToReplace)
        {
            var substraction = listToReplace.Except(listToInsert).ToList();

            /*foreach (var i in substraction)
             * {
             *  _context.Remove(i);
             * }*/
            foreach (var i in listToInsert)
            {
                try
                {
                    _context.Add(i);
                }
                catch (InvalidOperationException e)
                {
                    _context.Update(i);
                }
            }
        }