Example #1
0
        public IActionResult Index(string searchName = null, string searchEmail = null, string searchPhone = null, string Status = null)
        {
            OrderListVM orderListVM = new OrderListVM()
            {
                OrderHList = _orderHRepo.GetAll(),
                StatusList = WC.listStatus.ToList().Select(i => new Microsoft.AspNetCore.Mvc.Rendering.SelectListItem
                {
                    Text  = i,
                    Value = i
                })
            };

            if (!string.IsNullOrEmpty(searchName))
            {
                orderListVM.OrderHList = orderListVM.OrderHList.Where(u => u.FullName.ToLower().Contains(searchName.ToLower()));
            }
            if (!string.IsNullOrEmpty(searchEmail))
            {
                orderListVM.OrderHList = orderListVM.OrderHList.Where(u => u.Email.ToLower().Contains(searchEmail.ToLower()));
            }
            if (!string.IsNullOrEmpty(searchPhone))
            {
                orderListVM.OrderHList = orderListVM.OrderHList.Where(u => u.PhoneNumber.ToLower().Contains(searchPhone.ToLower()));
            }
            if (!string.IsNullOrEmpty(Status) && Status != "--Order Status--")
            {
                orderListVM.OrderHList = orderListVM.OrderHList.Where(u => u.OrderStatus.ToLower().Contains(Status.ToLower()));
            }

            return(View(orderListVM));
        }
        public IActionResult Index()
        {
            orderVM = new OrderVM
            {
                Orders = _iOrderH.GetAll()
            };

            return(View(orderVM));
        }
Example #3
0
        public IActionResult Index()
        {
            var    claimsIdentity = (ClaimsIdentity)User.Identity;
            var    claim          = claimsIdentity.FindFirst(ClaimTypes.NameIdentifier);
            HomeVM homeVM         = new HomeVM()
            {
                Products   = _prodRepo.GetAll(includeProperties: "Category"),
                Categories = _catRepo.GetAll(),
                OrderHList = _orderHRepo.GetAll()
            };

            if (User.IsInRole(WC.CustomerRole))
            {
                homeVM.CartList      = _cartRepo.GetAll(u => u.ApplicationUserId == claim.Value);
                homeVM.WishListItems = _wishDRepo.GetAll(u => u.ApplicationUserId == claim.Value);

                List <ShoppingCart> shoppingCartList = new List <ShoppingCart>();

                foreach (var item in homeVM.CartList)
                {
                    var obj = shoppingCartList.FirstOrDefault(u => u.ProductId == item.ProductId);
                    if (obj == null)
                    {
                        //cart item doesnot exist in session add it to session
                        shoppingCartList.Add(new ShoppingCart {
                            ProductId = item.ProductId, Qty = item.Qty
                        });
                    }
                }
                HttpContext.Session.Set(WC.SessionCart, shoppingCartList);


                List <WishList> wishLists = new List <WishList>();
                foreach (var item in homeVM.WishListItems)
                {
                    var obj = wishLists.FirstOrDefault(u => u.ProductId == item.ProductId);
                    if (obj == null)
                    {
                        // Product doesnot exist in wishlist session add it to session
                        wishLists.Add(new WishList {
                            ProductId = item.ProductId
                        });
                    }
                }
                HttpContext.Session.Set(WC.WishList, wishLists);


                return(View(homeVM));
            }
            else
            {
                return(View(homeVM));
            }
        }
        public List <Order> GetOrdersByCompany(Company company)
        {
            if (company == null)
            {
                throw new ArgumentNullException(nameof(company));
            }

            return(ExecuteFaultHandledOperation(() =>
            {
                var order_headers = new List <Order>();
                var comp = new CompanyData()
                {
                    CompanyKey = company.CompanyKey
                };
                var orders_data = _order_header_repo.GetAll(comp);

                foreach (OrderHeaderData order_data in orders_data)
                {
                    Order order_header = Map(order_data);
                    order_headers.Add(order_header);
                }
                return order_headers;
            }));
        }
Example #5
0
 public Task <List <Order> > GetOrdersAsync()
 {
     return(Task.Factory.StartNew(() => {
         return _orderEntityService.Map(_orderRepository.GetAll());
     }));
 }