Esempio n. 1
0
        public async Task DeleteCompressor(string symbol)
        {
            var compressorToDelete = Compressors.FirstOrDefault(x => x.Symbol == symbol);

            compressorToDelete.QuantityInStock = 0;
            await UpdateCompressor(compressorToDelete);
        }
Esempio n. 2
0
 public Compressor GetSelectedCompressor(string energy, string power = "180")
 {
     return(Compressors
            .Where(x => x.EnergyClass == energy)
            .Where(x => x.Power == power)
            .FirstOrDefault());
 }
Esempio n. 3
0
        public async Task UpdateCompressor(Compressor compressor)
        {
            var compressorToUpdate = Compressors.FirstOrDefault(x => x.Symbol == compressor.Symbol);

            compressorToUpdate.QuantityInStock = compressor.QuantityInStock;
            compressorToUpdate.Price           = compressor.Price;
            compressorToUpdate.Name            = compressor.Name;

            context.Compressor.Update(compressorToUpdate);
            await context.SaveChangesAsync();
        }
Esempio n. 4
0
 public async Task DeleteCompressor(string symbol)
 {
     try
     {
         var compressorToDelete = Compressors.FirstOrDefault(x => x.Symbol == symbol);
         context.Compressor.Remove(compressorToDelete);
         await context.SaveChangesAsync();
     }
     catch (Microsoft.EntityFrameworkCore.DbUpdateException)
     {
         return;
     }
 }
Esempio n. 5
0
        public decimal CalculateValue(Fridge fridge)
        {
            decimal value = Compressors.Where(x => x.Symbol == fridge.CompressorSymbol).SingleOrDefault().Price +
                            Bodies.Where(x => x.Symbol == fridge.BodySymbol).SingleOrDefault().Price;

            if (fridge.ShelfSet != null && fridge.ShelfSet.Count > 0)
            {
                foreach (var shelfSet in fridge.ShelfSet)
                {
                    value += Shelves.Where(x => x.Symbol == shelfSet.ShelfSymbol)
                             .SingleOrDefault().Price *shelfSet.Quantity;
                }
            }
            if (fridge.HandleSet != null && fridge.HandleSet.Count > 0)
            {
                foreach (var handleSet in fridge.HandleSet)
                {
                    value += Handles.Where(x => x.Symbol == handleSet.HandleSymbol)
                             .SingleOrDefault().Price *handleSet.Quantity;
                }
            }
            if (fridge.BalconySet != null && fridge.BalconySet.Count > 0)
            {
                foreach (var balconySet in fridge.BalconySet)
                {
                    value += Balconies.Where(x => x.Symbol == balconySet.BalconySymbol)
                             .SingleOrDefault().Price *balconySet.Quantity;
                }
            }
            if (fridge.AdditionalSet != null && fridge.AdditionalSet.Count > 0)
            {
                foreach (var additionalSet in fridge.AdditionalSet)
                {
                    value += Additionals.Where(x => x.Symbol == additionalSet.AdditionalEqSymbol)
                             .SingleOrDefault().Price;
                }
            }
            return(value * 1.25M);
        }
Esempio n. 6
0
 public Compressor GetCompressor(string symbol)
 {
     return(Compressors.FirstOrDefault(x => x.Symbol == symbol));
 }
Esempio n. 7
0
 public IQueryable <Compressor> GetAvailableCompressors()
 {
     return(Compressors.Where(x => x.QuantityInStock > 0));
 }
Esempio n. 8
0
 public IEnumerable <Compressor> GetCompressors()
 {
     return(Compressors.AsEnumerable());
 }
Esempio n. 9
0
        private static void ParseXml()
        {
            XElement xe = XElement.Load(@"C:\Users\perivar.nerseth\OneDrive\Audio\Presets\Izotope\Nectar 2\Presets\TEST.xml");

            // Compressors:
            // Dynamics 1 and Dynamics 2
            // Bypass
            // Attack
            // Gain
            // Mode
            // RMS Detection
            // Ratio
            // Release
            // Threshold
            var comp  = new Compressors();
            var xComp = (from a in xe.Element("Compressors").Elements("Param")
                         //where a.Attribute("ElementID").Value.Equals("Dynamics 1")
                         select new CompressorsParam
            {
                ElementID = a.Attribute("ElementID").Value,
                ParamID = a.Attribute("ParamID").Value,
                Value = NumberUtils.DecimalTryParseOrZero(a.Attribute("Value").Value)
            }).ToList();

            comp.CompressorsParam = xComp;

            // Delay
            var del  = new Delay();
            var xDel = (from a in xe.Element("Delay").Elements("Param")
                        select new DelayParam
            {
                ElementID = a.Attribute("ElementID").Value,
                ParamID = a.Attribute("ParamID").Value,
                Value = NumberUtils.DecimalTryParseOrZero(a.Attribute("Value").Value)
            }).ToList();

            del.DelayParam = xDel;

            // Reverb
            var rev     = new Reverb();
            var xReverb = (from a in xe.Element("Reverb").Elements("Param")
                           select new ReverbParam
            {
                ElementID = a.Attribute("ElementID").Value,
                ParamID = a.Attribute("ParamID").Value,
                Value = NumberUtils.DecimalTryParseOrZero(a.Attribute("Value").Value)
            }).ToList();

            rev.ReverbParam = xReverb;

            // EQ
            var eq = new EQ();
            // Band 2 Enable
            // Band 2 Frequency
            // Band 2 Gain
            // Band 2 Shape
            // Band 0 - 7
            var xEQ = (from a in xe.Element("EQ").Elements("Param")
                       where a.Attribute("ParamID").Value.StartsWith("Band 4")
                       select new EQParam
            {
                ElementID = a.Attribute("ElementID").Value,
                ParamID = a.Attribute("ParamID").Value,
                Value = NumberUtils.DecimalTryParseOrZero(a.Attribute("Value").Value)
            }).ToList();

            eq.EQParam = xEQ;
        }