public ActionResult Export()
        {
            using (XLWorkbook workbook = new XLWorkbook(XLEventTracking.Disabled))
            {
                var parser = new ExcelParser(_context);
                parser.addComputersToExcel(workbook);

                /*parser.addCoolersToExcel(workbook);
                *  parser.addCpusToExcel(workbook);
                *  parser.addDrivesToExcel(workbook);
                *  parser.addGpuInterfacesToExcel(workbook);
                *  parser.addGpusToExcel(workbook);
                *  parser.addMotherboardsToExcel(workbook);
                *  parser.addPowerSuppliesToExcel(workbook);
                *  parser.addRamsToExcel(workbook);
                *  parser.addRamTypesToExcel(workbook);
                *  parser.addSocketsToExcel(workbook);*/
                using (var stream = new MemoryStream())
                {
                    workbook.SaveAs(stream);
                    stream.Flush();
                    return(new FileContentResult(stream.ToArray(),
                                                 "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
                    {
                        FileDownloadName = $"computers_{DateTime.UtcNow.ToShortDateString()}.xlsx"
                    });
                }
            }
        }
        public async Task <IActionResult> Import(IFormFile fileExcel)
        {
            if (ModelState.IsValid)
            {
                if (fileExcel != null)
                {
                    using (var stream = new FileStream(fileExcel.FileName, FileMode.Create))
                    {
                        await fileExcel.CopyToAsync(stream);

                        using (XLWorkbook workBook = new XLWorkbook(stream, XLEventTracking.Disabled))
                        {
                            var parser    = new ExcelParser(_context);
                            var computers = parser.getComputersFromExcel(workBook);

                            /*var coolers = parser.getCoolersFromExcel(workBook);
                            *  var cpus = parser.getCpusFromExcel(workBook);
                            *  var drives = parser.getDrivesFromExcel(workBook);
                            *  var gpuInterfaces = parser.getGpuInterfacesFromExcel(workBook);
                            *  var gpu = parser.getGpusFromExcel(workBook);
                            *  var motherboards = parser.getMotherboardsFromExcel(workBook);
                            *  var powerSupplies = parser.getPowerSuppliesFromExcel(workBook);
                            *  var rams = parser.getRamsFromExcel(workBook);
                            *  var ramTypes = parser.getRamTypesFromExcel(workBook);
                            *  var sockets = parser.getSocketsFromExcel(workBook);*/

                            /*List<SocketsToCooler> socketsToCoolers = new List<SocketsToCooler>();
                             * for (int i = 0; i < coolers.Count(); i++)
                             * {
                             *  for (int k = 0; k < coolers.ElementAt(i).SocketsToCoolers.Count(); k++)
                             *  {
                             *      var temp = new SocketsToCooler
                             *      {
                             *          CoolerId = coolers.ElementAt(i).Id,
                             *          SocketId = coolers.ElementAt(i).SocketsToCoolers.ElementAt(k).SocketId
                             *      };
                             *      coolers.ElementAt(i).SocketsToCoolers.Add(temp);
                             *      socketsToCoolers.Add(temp);
                             *  }
                             * }*/
                            //replaceListInDB(socketsToCoolers, _context.SocketsToCoolers.ToList(),new SocketsToCoolerComparer());
                            insertComputers(computers.ToList());
                            //replaceListInDB(coolers, _context.Coolers.ToList());
                            //replaceListInDB(cpus,  _context.Cpus.ToList());
                            //replaceListInDB(drives, _context.Drives.ToList());
                            //replaceListInDB(gpuInterfaces,  _context.Gpuinterfaces.ToList());
                            //replaceListInDB(gpu,  _context.Gpus.ToList());
                            //replaceListInDB(motherboards, _context.Motherboards.ToList());
                            //replaceListInDB(powerSupplies,  _context.PowerSupplies.ToList());
                            //replaceListInDB(rams,  _context.Rams.ToList());
                            //replaceListInDB(ramTypes, _context.Ramtypes.ToList());
                            //replaceListInDB(sockets,  _context.Sockets.ToList());
                            //setIdentityInsert();
                            await _context.SaveChangesAsync();

                            List <RamsToComputer> ramToComputers = new List <RamsToComputer>();
                            for (int i = 0; i < computers.Count(); i++)
                            {
                                for (int k = 0; k < computers.ElementAt(i).SelectedRam.Count(); k++)
                                {
                                    var temp = new RamsToComputer
                                    {
                                        ComputerId = computers.ElementAt(i).Id,
                                        Ramid      = computers.ElementAt(i).SelectedRam[k]
                                    };
                                    computers.ElementAt(i).RamsToComputers.Add(temp);
                                    _context.Add(temp);
                                }
                            }
                            List <ComputersToDrive> drivesToComputers = new List <ComputersToDrive>();
                            for (int i = 0; i < computers.Count(); i++)
                            {
                                for (int k = 0; k < computers.ElementAt(i).SelectedDrive.Count(); k++)
                                {
                                    var temp = new ComputersToDrive
                                    {
                                        ComputerId = computers.ElementAt(i).Id,
                                        DriveId    = computers.ElementAt(i).SelectedDrive[k]
                                    };
                                    computers.ElementAt(i).ComputersToDrives.Add(temp);
                                    _context.Add(temp);
                                }
                            }

                            //replaceListInDB(ramToComputers, _context.RamsToComputers.ToList(),new RamsToComputerComparer());
                            //replaceListInDB(drivesToComputers, _context.ComputersToDrives.ToList(),new ComputersToDriveComparer());
                            await _context.SaveChangesAsync();

                            //setIdentityNotInsert();
                        }
                    }
                }
            }
            return(RedirectToAction(nameof(Index)));
        }