Ejemplo n.º 1
0
        public double Buy(params string[] basketByNames)
        {
            Dictionary <Category, Dictionary <Catalog, int> > DicoByCategory = new Dictionary <Category, Dictionary <Catalog, int> >();

            foreach (string name in basketByNames)
            {
                Catalog catalog;
                bool    catalogExists = Catalogs.TryGetValue(name, out catalog);
                if (!catalogExists)
                {
                    throw new Exception($"{catalog.Name} is unkown");
                }
                Category category;
                bool     categoryExists = Categories.TryGetValue(catalog.Category, out category);
                if (!categoryExists)
                {
                    throw new Exception($"{category.Name} dosen't exists");
                }
                GenerateDico(DicoByCategory, catalog, category);
            }
            try
            {
                return(GetPrices(DicoByCategory));
            }
            catch (NotEnoughInventoryException ex)
            {
                throw ex;
            }
            catch (Exception)
            {
                throw;
            }
        }
Ejemplo n.º 2
0
        public int Quantity(string name)
        {
            Catalog catalog;
            bool    IsExist = Catalogs.TryGetValue(name, out catalog);

            if (IsExist)
            {
                return(catalog.Quantity);
            }
            return(0);
        }