예제 #1
0
        //add also in view to view the access denied
        public IActionResult Get(string status = null)
        {
            List <OrderDetailsViewModel> orderListVM = new List <OrderDetailsViewModel>();

            IEnumerable <OrderHeader> OrderHeaderList;


            //if role is customer
            if (User.IsInRole(SD.CustomerRole))
            {
                //retrieve customer orders

                //need the identity for that customer
                var claimsIdentity = (ClaimsIdentity)User.Identity;

                var claim = claimsIdentity.FindFirst(ClaimTypes.NameIdentifier);

                OrderHeaderList = _unitOfWork.OrderHeader.GetAll(u => u.UserId == claim.Value, null, "ApplicationUser");
            }
            else
            {
                OrderHeaderList = _unitOfWork.OrderHeader.GetAll(null, null, "ApplicationUser");
            }

            //get the status
            if (status == "cancelled")
            {
                OrderHeaderList = OrderHeaderList.Where(o => o.Status == SD.StatusCancelled || o.Status == SD.StatusRefunded || o.Status == SD.PaymentStatusRejected);
            }
            else
            {
                if (status == "completed")
                {
                    OrderHeaderList = OrderHeaderList.Where(o => o.Status == SD.StatusCompleted);
                }
                else
                {
                    OrderHeaderList =
                        OrderHeaderList.Where(o => o.Status == SD.StatusReady || o.Status == SD.StatusInProcess || o.Status == SD.StatusSubmitted || o.Status == SD.PaymentStatusPending);
                }
            }


            //then populate orders
            foreach (OrderHeader item in OrderHeaderList)
            {
                OrderDetailsViewModel individual = new OrderDetailsViewModel
                {
                    OrderHeader = item,
                    //get the item from database
                    OrderDetails = _unitOfWork.OrderDetails.GetAll(o => o.OrderId == item.Id).ToList()
                };
                //then add the list to viewmodel
                orderListVM.Add(individual);
            }
            //return as json response
            return(Json(new { data = orderListVM }));
        }
예제 #2
0
        public IActionResult Get(string status = null)
        {
            List <OrderDetailsViewModel> orderListVM = new List <OrderDetailsViewModel>();
            IEnumerable <OrderHeader>    OrderHeaderList;

            if (User.IsInRole(SD.CustomerRole))
            {
                //retrive all orders for that customer
                var claimsIdentity = (ClaimsIdentity)User.Identity;
                var claim          = claimsIdentity.FindFirst(ClaimTypes.NameIdentifier);
                OrderHeaderList = _unitOfWork.OrderHeader.GetAll(u => u.UserId == claim.Value, null, "ApplicationUser");
            }
            else
            {
                OrderHeaderList = _unitOfWork.OrderHeader.GetAll(null, null, "ApplicationUser");
            }


            if (status == "cancelled")
            {
                OrderHeaderList =
                    OrderHeaderList.Where(o => o.Status == SD.StatusCancelled || o.Status == SD.StatusRefunded || o.Status == SD.PaymentStatusRejected);
            }
            else
            {
                if (status == "completed")
                {
                    OrderHeaderList = OrderHeaderList.Where(o => o.Status == SD.StatusCompleted);
                }
                else
                {
                    OrderHeaderList = OrderHeaderList.Where(o =>
                                                            o.Status == SD.StatusReady || o.Status == SD.StatusInProcess ||
                                                            o.Status == SD.StatusSubmitted || o.Status == SD.PaymentStatusPending);
                }
            }

            foreach (OrderHeader item in OrderHeaderList)
            {
                OrderDetailsViewModel individual = new OrderDetailsViewModel
                {
                    OrderHeader  = item,
                    OrderDetails = _unitOfWork.OrderDetail.GetAll(o => o.OrderId == item.Id).ToList()
                };

                orderListVM.Add(individual);
            }

            return(Json(new { data = orderListVM }));
        }
예제 #3
0
        [Authorize]                                    // sadece login olanların order listesini görmesin isağlar..
        public IActionResult Get(string status = null) // status boş ise hepsini sıralar.. aşağıda else de diğer şartlar var..
        {
            List <OrderDetailsVM> orderListVM = new List <OrderDetailsVM>();

            IEnumerable <OrderHeader> OrderHeaderList;

            if (User.IsInRole(StaticValues.CustomerRole))
            {
                //retrieve all orders for that customer
                var claimsIdentity = (ClaimsIdentity)User.Identity;
                var claim          = claimsIdentity.FindFirst(ClaimTypes.NameIdentifier);
                OrderHeaderList = _unitOfWork.OrderHeader.GetAll(u => u.UserId == claim.Value, null, "ApplicationUser");
            }
            else // eger role customer değilse bütün orderleri alacağız
            {
                OrderHeaderList = _unitOfWork.OrderHeader.GetAll(null, null, "ApplicationUser");
            }

            if (status == "cancelled")
            {
                OrderHeaderList = OrderHeaderList.Where(o => o.Status == StaticValues.StatusCancelled || o.Status == StaticValues.StatusRefunded || o.Status == StaticValues.PaymentStatusRejected); // cancelled ve diğer cancel etme türleri refunded ile ödeme reddedildiler de sıralanacak
            }
            else
            {
                if (status == "completed")
                {
                    OrderHeaderList = OrderHeaderList.Where(o => o.Status == StaticValues.StatusCompleted);
                }
                else // status inprocess, ready for pickup veya submitted...
                {
                    OrderHeaderList = OrderHeaderList.Where(o => o.Status == StaticValues.StatusReady || o.Status == StaticValues.StatusInProcess || o.Status == StaticValues.StatusSubmitted || o.Status == StaticValues.PaymentStatusPending);
                }
            }

            foreach (OrderHeader item in OrderHeaderList)
            {
                OrderDetailsVM individual = new OrderDetailsVM
                {
                    OrderHeader  = item,
                    OrderDetails = _unitOfWork.OrderDetails.GetAll(o => o.OrderId == item.Id).ToList()
                };
                orderListVM.Add(individual);
            }

            return(Json(new { data = orderListVM }));
        }
예제 #4
0
        public IActionResult Get(string status = null)
        {
            List <OrderDetailsVM> orderListVM = new List <OrderDetailsVM>();

            IEnumerable <OrderHeader> OrderHeaderList;

            if (User.IsInRole(StaticDetails.CustomerRole))
            {
                //Retrive all orders for that customer
                var claimsIdentity = (ClaimsIdentity)User.Identity;
                var claim          = claimsIdentity.FindFirst(ClaimTypes.NameIdentifier);
                OrderHeaderList = _unitOfWork.OrderHeader.GetAll(u => u.UserId == claim.Value, null, "ApplicationUser");
            }
            else
            {
                OrderHeaderList = _unitOfWork.OrderHeader.GetAll(null, null, "ApplicationUser");
            }

            switch (status)
            {
            case StaticDetails.StatusCancelled: OrderHeaderList = OrderHeaderList.Where(o => o.Status == StaticDetails.StatusCancelled || o.Status == StaticDetails.StatusRefunded || o.Status == StaticDetails.PaymentStatusRejected); break;

            case StaticDetails.StatusCompleted: OrderHeaderList = OrderHeaderList.Where(o => o.Status == StaticDetails.StatusCompleted); break;

            default: OrderHeaderList = OrderHeaderList.Where(o => o.Status == StaticDetails.StatusReady || o.Status == StaticDetails.StatusInProcess || o.Status == StaticDetails.StatusSubmitted || o.Status == StaticDetails.PaymentStatusPending); break;
            }
            ;

            foreach (OrderHeader item in OrderHeaderList)
            {
                OrderDetailsVM orderDetailItem = new OrderDetailsVM
                {
                    OrderHeader  = item,
                    OrderDetails = _unitOfWork.OrderDetails.GetAll(o => o.OrderId == item.Id).ToList()
                };

                orderListVM.Add(orderDetailItem);
            }

            return(Json(new { data = orderListVM }));
        }