Ejemplo n.º 1
0
        public ActionResult ListAllOrders(bool? showInactive, Guid? distributor, string command, string StartDate, string EndDate, string orderRef = "", int itemsperpage = 10, int page = 1)
        {
            // never remove this line below
            Session["PurchaseOrderLineItemList"] = null;
            bool showinactive = false;
            if (showInactive != null)
                showinactive = (bool)showInactive;
            ViewBag.showInactive = showinactive;
            Stopwatch stopWatch = new Stopwatch();
            if (command == "Clear")
            {
                orderRef = "";
            }
            ViewBag.searchParam = orderRef;
            try
            {
                if (itemsperpage != null)
                {
                    ViewModelBase.ItemsPerPage = itemsperpage;
                }
                stopWatch.Start();
            
                if (TempData["msg"] != null)
                {
                    ViewBag.msg = TempData["msg"].ToString();
                    ViewBag.NoOrders = TempData["msg"].ToString();
                    TempData["msg"] = null;
                }
                
                ViewBag.DistributorList = _listOrdersViewModelBuilder.GetDistributor();

                int currentPageIndex = page < 0 ? 0 : page - 1;
                int take = itemsperpage;
                int skip = currentPageIndex * take;

                var query = new QueryOrders();
                query.ShowInactive = showinactive;
                query.Skip = skip;
                query.Take = take;
                query.Name = orderRef;
                query.DocumentStatus=DocumentStatus.Confirmed;

                if (command == "Filter" || command == "Clear" || command == "Search")
                {
                    query.Distributr = distributor ?? Guid.Empty;
                    query.StartDate = DateTime.Parse(StartDate);
                    query.EndDate = DateTime.Parse(EndDate);
                }
               
               
                var orderList = _listOrdersViewModelBuilder.Query(query);
                var data = orderList.Data;
                var count = orderList.Count;
               
                stopWatch.Stop();

                TimeSpan ts = stopWatch.Elapsed;
                 
                string elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}",
                    ts.Hours, ts.Minutes, ts.Seconds,
                    ts.TotalMilliseconds);
                
                stopWatch.Reset();
                _auditLogViewModelBuilder.AddAuditLog(this.User.Identity.Name, "List Order Timer", "Order Controller" + elapsedTime, DateTime.Now);
                _log.InfoFormat("List All Orders\tTime taken to get all orders" + elapsedTime);

                return View(data.ToPagedList(currentPageIndex, ViewModelBase.ItemsPerPage,count));
            }
            catch (Exception ex)
            {
                ViewBag.msg = ex.Message;
                return View();
            }
        }
Ejemplo n.º 2
0
        public ActionResult ApprovedPurchaseOrders(int? distributor, int? page, string ord, string StartDate, string EndDate, int itemsperpage = 10)
        {
            if (page.HasValue)
                page = page.Value;
            else page = 0;

            if (itemsperpage != null)
            {
                ViewModelBase.ItemsPerPage = itemsperpage;
            }
            var query = new QueryOrders();
            int take = itemsperpage;
            int skip = page.Value * take;
            query.Skip = skip;
            query.Take = take;
            query.OrderType = OrderType.DistributorToProducer;
            query.DocumentStatus = DocumentStatus.Approved;
            query.EndDate = DateTime.Now;
            query.StartDate = DateTime.Now.AddDays(-90);
            int pageSize = itemsperpage;

            var approvedOrderList = _listOrdersViewModelBuilder.Query(query);
            var data = approvedOrderList.Data;
            var count = approvedOrderList.Count;
           // OrderViewModel approvedOrderList = _listOrdersViewModelBuilder.GetAllApprovedOrders(page.Value, pageSize);
            
            return View(data.ToPagedList(page.Value, itemsperpage, count));
        }
Ejemplo n.º 3
0
       public ActionResult DeliveredPurchaseOrders(int? distributor, string ord, string startDate, string endDate, int itemsperpage = 10, int page = 1)
        {
          
            int currentPageIndex = page < 0 ? 0 : page - 1;
            if (itemsperpage != null)
            {
                ViewModelBase.ItemsPerPage = itemsperpage;
            }

            var query = new QueryOrders();
            int take = itemsperpage;
            int skip = currentPageIndex * take;
            query.Skip = skip;
            query.Take = take;
            query.OrderType = OrderType.DistributorToProducer;
            query.DocumentStatus = DocumentStatus.Closed;
            query.EndDate = DateTime.Now;
            query.StartDate = DateTime.Now.AddDays(-90);

            var deliveredOrderList = _listOrdersViewModelBuilder.Query(query);
            var data = deliveredOrderList.Data;
            var count = deliveredOrderList.Count;
            

            int pageSize = itemsperpage;

            return View(data.ToPagedList(currentPageIndex, itemsperpage, count));

           // OrderViewModel deliveredOrderList = _listOrdersViewModelBuilder.GetAllClosedPurchaseOrders(currentPageIndex, pageSize);

           //return View(deliveredOrderList);
        }
Ejemplo n.º 4
0
        public ActionResult PendingOrders(int? distributor, int? page, string ord, string startDate, string endDate, int itemsperpage = 10)
        {
            if (page.HasValue)
                page = page.Value-1;// page = page.Value;
            else page = 0;//page=1;

            var query = new QueryOrders();
            int take = itemsperpage;
            int skip = page.Value * take;
            query.Skip = skip;
            query.Take = take;
            query.OrderType = OrderType.DistributorToProducer;
            query.DocumentStatus = DocumentStatus.Confirmed;
            query.EndDate = DateTime.Now;
            query.StartDate = DateTime.Now.AddDays(-90);

           var pendingOrderList=_listOrdersViewModelBuilder.Query(query);
           var data = pendingOrderList.Data;
           var count = pendingOrderList.Count;

            return View(data.ToPagedList(page.Value, itemsperpage, count));
            //OrderViewModel pendingOrderList = _listOrdersViewModelBuilder.GetAllPendingOrders(page.Value, itemsperpage);

            //return View(pendingOrderList);
        }
Ejemplo n.º 5
0
        public QueryResult<Order> Query(QueryOrders query)
        {
            IEnumerable<tblDocument> tblDocument;
            tblDocument = _GetAll(DocumentType.Order).AsQueryable();
            tblDocument = tblDocument.Where(k => k.DocumentStatusId == (int)query.DocumentStatus);

            tblDocument = tblDocument.Where(k => k.DocumentDateIssued >= query.StartDate && k.DocumentDateIssued <= query.EndDate);
            tblDocument = tblDocument.Where(k => k.OrderOrderTypeId == (int)query.OrderType);

            var queryResult = new QueryResult<Order>();
           
            if (query.Distributr != null && query.Distributr != Guid.Empty)
            {
                tblDocument = tblDocument.Where(k => k.DocumentIssuerCostCentreId == query.Distributr);
            }
            queryResult.Count = tblDocument.Count();

            tblDocument = tblDocument.OrderBy(l => l.DocumentDateIssued);


            if (!string.IsNullOrWhiteSpace(query.Name))
            {
                var outletIds =
                    _ctx.tblCostCentre.Where(s => s.CostCentreType == 5 && s.Name.Contains(query.Name))
                        .Select(s => s.Id);
                tblDocument = tblDocument.Where(l =>l.OrderIssuedOnBehalfOfCC != null && outletIds.Contains( l.OrderIssuedOnBehalfOfCC.Value));
            }

            if (query.Skip.HasValue && query.Take.HasValue)
            {

                tblDocument = tblDocument.Skip(query.Skip.Value)
                    .Take(query.Take.Value);
            }
            var entities = tblDocument.ToList().Select(Map);
               
            queryResult.Data = entities.ToList();
            
            return queryResult;
        }
        public QueryResult<OrderViewModel> Query(QueryOrders query)
        {
            var orders = _orderRepository.Query(query);

            var result = new QueryResult<OrderViewModel>();
            if (!orders.Data.Any())
                return new QueryResult<OrderViewModel>();
            result.Data = orders.Data.Select(Map).ToList();
            result.Count = orders.Count;

            return result;
        }