Esempio n. 1
0
        public void FillSku(int corporationId)
        {
            var corporation = Get <CorporationWallet>(c => c.Id == corporationId);

            if (corporation == null)
            {
                throw new BillingNotFoundException("Corporation not found");
            }
            var specialissations = GetList <CorporationSpecialisation>(c => c.CorporationId == corporationId);

            foreach (var specialisation in specialissations)
            {
                var nomenklaturas = GetList <Nomenklatura>(n => n.SpecialisationId == specialisation.SpecialisationId, n => n.Specialisation);
                foreach (var nomenklatura in nomenklaturas)
                {
                    var sku = Get <Sku>(s => s.NomenklaturaId == nomenklatura.Id && s.CorporationId == corporationId);
                    if (sku != null)
                    {
                        continue;
                    }
                    var enabled = true;
                    if (nomenklatura.Specialisation.Name.Contains("анлок"))
                    {
                        enabled = false;
                    }
                    var price = BillingHelper.GetSpecialisationPrice(specialisation, nomenklatura);
                    sku = new Sku
                    {
                        CorporationId  = corporationId,
                        Count          = nomenklatura.BaseCount,
                        Enabled        = enabled,
                        Name           = $"{nomenklatura.Name} ({corporation.Name})",
                        Nomenklatura   = nomenklatura,
                        NomenklaturaId = nomenklatura.Id,
                        Price          = price
                    };
                    AddAndSave(sku);
                }
            }
        }