Esempio n. 1
0
        public void Execute()
        {
            Console.WriteLine("What percentage relative to maxStock should be considered as running out of stock? (0-100)");
            double percentagemRutura = Double.Parse(Console.ReadLine());

            Console.WriteLine("Which franchisee is making the order?");
            int fid = int.Parse(Console.ReadLine());

            List <Entrega> produtosEmRutura;


            using (var das = new DataAccessScope(true))
            {
                IMapperProdVendidoPorFranqueado map   = new MapperProdVendidoPorFranqueado();
                List <ProdVendidoPorFranqueado> lpvpf = map.GetOutOfStock(percentagemRutura, fid);
                produtosEmRutura = lpvpf.Select(pvpf => ToEntrega(pvpf)).ToList();
                das.Commit();
            }

            using (var das = new DataAccessScope(true))
            {
                IMapperEntrega map = new MapperEntrega();
                map.OrderOutOfStock(produtosEmRutura);
                das.Commit();
            }
        }
Esempio n. 2
0
        private void ObtainAverage()
        {
            Console.WriteLine("Choose Prod Id to obtain Average");
            int prodId;

            while (!int.TryParse(Console.ReadLine(), out prodId))
            {
                Console.WriteLine("Invalid number, please try again!");
            }

            using (var das = new DataAccessScope(true))
            {
                IMapperProdVendidoPorFranqueado map = new MapperProdVendidoPorFranqueado();
                List <AvgSale> avgSales             = map.AvgSalesInPresentYear(prodId);
                if (avgSales.Count == 0)
                {
                    Console.WriteLine("Product with id = {0} did not sell any units this year", prodId);
                }
                foreach (AvgSale avg in avgSales)
                {
                    Console.WriteLine("Product {0} sold on average {1} units during this year", avg.ProdId, avg.Avg);
                }
                Console.WriteLine("Press any key to continue");
                Console.ReadKey();
            }
        }
Esempio n. 3
0
 private void RemoveFranchiseeFromProdVendidoPorFranqueado(int franqId)
 {
     using (var das = new DataAccessScope(true))
     {
         IMapperProdVendidoPorFranqueado map = new MapperProdVendidoPorFranqueado();
         map.DeleteAllWithFranqId(franqId);
         das.Commit();
     }
 }
Esempio n. 4
0
 private void UpdateStock(List <ProdutoViewInStore> sale)
 {
     using (var das = new DataAccessScope(true))
     {
         IMapperProdVendidoPorFranqueado map = new MapperProdVendidoPorFranqueado();
         map.UpdateInBulk(franqId, sale);
         das.Commit();
     }
 }
 public void Execute()
 {
     using (var das = new DataAccessScope(true))
     {
         IMapperProdVendidoPorFranqueado map = new MapperProdVendidoPorFranqueado();
         List <TopSales> q = map.SalesByFranchiseeThisYear();
         foreach (var a in q)
         {
             Console.WriteLine("Franchisee nº {0} sold {1} EUR this year!", a.FranqId, a.VendasAnoCorrente);
         }
     }
 }
Esempio n. 6
0
        private void RefreshProductsCache()
        {
            List <ProdVendidoPorFranqueado> prodsVendidosPorFranqueado;

            using (var das = new DataAccessScope(true))
            {
                IMapperProdVendidoPorFranqueado map = new MapperProdVendidoPorFranqueado();

                prodsVendidosPorFranqueado = map.GetAllInFranchisee(franqId);
            }
            using (var das = new DataAccessScope(true))
            {
                IMapperProduto map = new MapperProduto();
                productsCache = map
                                .GetAll()
                                .Zip(prodsVendidosPorFranqueado, (p, pvpf) => ProdutoViewInStore.Parse(p, pvpf))
                                .ToList();
            }
        }
Esempio n. 7
0
        public void Execute()
        {
            Console.WriteLine("Add a Prod");

            Produto p = PromptUserToBuildProduct();

            using (var das = new DataAccessScope(true))
            {
                IMapperProduto map = new MapperProduto();
                map.Create(p);
                das.Commit();
            }
            Console.WriteLine("Product created with id = {0}", p.id);

            ProdVendidoPorFranqueado pvpf = PromptUserToBuildProdVendidoPorFranqueado();

            using (var das = new DataAccessScope(true))
            {
                IMapperProdVendidoPorFranqueado map = new MapperProdVendidoPorFranqueado();
                map.Create(pvpf);
                das.Commit();
            }
        }