Exemplo n.º 1
0
        public ActionResult GetByFilter(string manager, string product, string date)
        {
            SaleRowsModel saleRowsModel = new SaleRowsModel();
            var           newManager    = managerRepository.GetEntity(new DAL.Models.Manager()
            {
                ManagerName = manager
            });

            if (newManager != null)
            {
                var dataM = saleInfoRepository.Items.Where(x => x.ID_Manager == newManager.ID_Manager);

                foreach (var saleInfo in dataM)
                {
                    var newDate     = saleInfo.SaleDate;
                    var managerName = managerRepository.GetEntityNameById(saleInfo.ID_Manager.Value);
                    var clientName  = clientRepository.GetEntityNameById(saleInfo.ID_Client.Value);
                    var newProduct  = productRepository.GetEntityNameById(saleInfo.ID_Product.Value);
                    saleRowsModel.ListRow.Add(new SaleRowModel()
                    {
                        ManagerName = managerName.ManagerName, Date = newDate, ClientName = clientName.ClientName, ProductName = newProduct.ProductName, ProductCost = newProduct.ProductCost
                    });
                }
            }
            if (!string.IsNullOrEmpty(product) && !product.Equals("-"))
            {
                saleRowsModel.ListRow = saleRowsModel.ListRow.Where(x => x.ProductName.Equals(product)).ToList();
            }
            if (!string.IsNullOrEmpty(date))
            {
                saleRowsModel.ListRow = saleRowsModel.ListRow.Where(x => x.Date.Contains(date)).ToList();
            }
            return(View("~/Areas/Default/Views/Saleinfo/SaleRows.cshtml", saleRowsModel));
        }
Exemplo n.º 2
0
        public ActionResult Index(int page = 1)
        {
            //var list = saleInfoRepository.Items.OrderByDescending(x => x.ID_Sale);
            SaleRowsModel saleRowsModel = new SaleRowsModel();
            //var newManager = managerRepository.GetEntity(new DAL.Models.Manager() { ManagerName = manager });
            //if (newManager != null)
            //{
            var dataM = saleInfoRepository.Items.Select(x => x);

            foreach (var saleInfo in dataM)
            {
                var newDate     = saleInfo.SaleDate;
                var managerName = managerRepository.GetEntityNameById(saleInfo.ID_Manager.Value);
                var clientName  = clientRepository.GetEntityNameById(saleInfo.ID_Client.Value);
                var newProduct  = productRepository.GetEntityNameById(saleInfo.ID_Product.Value);
                saleRowsModel.ListRow.Add(new SaleRowModel()
                {
                    ManagerName = managerName.ManagerName, Date = newDate, ClientName = clientName.ClientName, ProductName = newProduct.ProductName, ProductCost = newProduct.ProductCost
                });
            }

            //}
            return(View(saleRowsModel));
        }