public ActionResult InsertBulk(string mainToken, List <SolarSystemStructureDto> dtos)
        {
            var main     = _characterService.GetMainCharacterByToken(mainToken);
            var maskId   = main.MaskType == MaskType.Alliance && main.Pilot.Corporation.AllianceId != null ? main.Pilot.Corporation.Alliance.MaskId : main.Pilot.Corporation.MaskId;
            var addList  = new List <SolarSystemStructure>();
            var shipList = new List <DscanShip>();

            foreach (var dto in dtos)
            {
                var itemType = _itemTypeService.GetItemTypeById(dto.ItemTypeId);
                if (itemType.ItemGroup.ItemCategory.Name == "Structure")
                {
                    addList.Add(new SolarSystemStructure
                    {
                        Name          = dto.Name,
                        Description   = dto.Description,
                        SolarSystemId = dto.SolarSystemId,
                        MaskId        = maskId,
                        ItemTypeId    = dto.ItemTypeId,
                    });
                }
                if (itemType.ItemGroup.ItemCategory.Name == "Ship")
                {
                    shipList.Add(new DscanShip
                    {
                        ShipName   = dto.Name,
                        ShipTypeId = dto.ItemTypeId,
                    });
                }
            }
            if (shipList.Any())
            {
                var dscan = new Dscan
                {
                    DscanShips    = shipList,
                    MaskId        = maskId,
                    SolarSystemId = dtos.First().SolarSystemId
                };
                _dscanService.Insert(dscan);
            }
            _solarSystemStructureService.InsertBulk(addList);
            return(Ok());
        }
Пример #2
0
 public void Update(Dscan dscan)
 {
     _context.Update(dscan);
     _context.SaveChanges();
 }
Пример #3
0
 public void Insert(Dscan dscan)
 {
     _context.Dscans.Add(dscan);
     _context.SaveChanges();
 }