Ejemplo n.º 1
0
        public IList <Order> GetOrders(SearchOrderModel searchOrder)
        {
            if (!searchOrder.Validate())
            {
                throw new ArgumentException("SearchOrderModel didn't pass validation");
            }

            return(_context.Query <Order>($@"
                    SELECT
                        OrderId
                        ,CustomerId
                        ,ProductId
                        ,OrderWeight
                        ,OrderDate
                        ,CreatedDate
                    FROM
                        Orders
                     {CreateQuery(searchOrder)}
                   ORDER BY {searchOrder.OrderBy}{(searchOrder.IsDesc ? " DESC" : string.Empty)}
                    OFFSET @skip ROWS
                    FETCH NEXT @take ROWS ONLY
                ", new
            {
                skip = searchOrder.Skip,
                take = searchOrder.Take
            }).ToList());
        }
Ejemplo n.º 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            SearchOrder su = new SearchOrder(CurrentAdmin, CurrentLanguage.Code);

            model    = su.Model;
            callback = RequestTool.RequestString("callback");
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> Index([Bind] SearchOrderModel order)
        {
            if (!ModelState.IsValid)
            {
                _logger.LogInformation($"!ModelState.IsValid");
                return(View(order));
            }

            if (string.IsNullOrEmpty(order.Id))
            {
                _logger.LogInformation($"string.IsNullOrEmpty(order.Id)");
                ModelState.AddModelError("", "OrderId can't be null or empty!!!");
                return(View(order));
            }
            var orderData = await _orderService.FindOrderById(order.Id);

            if (orderData == null)
            {
                ModelState.AddModelError("", "OrderId Not found");
                return(View(order));
            }
            _logger.LogInformation($"RedirectToAction: {order.Id}");

            return(RedirectToAction("OrderDetails", "Payment", new { Id = order.Id }));
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 订单列表页
        /// zhoub 20150713
        /// </summary>
        /// <param name="searchModel"></param>
        /// <returns></returns>
        public JsonResult List(SearchOrderModel searchModel)
        {
            var result = _acOrederService.GetPagingOrder(searchModel);

            var data = new
            {
                rows  = result.Data,
                total = result.Data.TotalCount
            };

            return(Json(data, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 5
0
        public async Task <PaginatedResult <Order> > SearchAsync(SearchOrderModel rq)
        {
            var queryObject = QueryObject <Order> .Empty;

            //Filter by start date
            if (rq.StartDate.HasValue)
            {
                var startDate = rq.StartDate.Value;
                queryObject.And(new OrderQueryObject.FilterByStartDate(startDate));
            }

            //Filter by end date
            if (rq.EndDate.HasValue)
            {
                var endDate = rq.EndDate.Value;
                queryObject.And(new OrderQueryObject.FilterByEndDate(endDate));
            }

            //Filter by status
            if (rq.Status != null)
            {
                var status = (OrderStatuses)rq.Status;
                queryObject.And(new OrderQueryObject.HasStatus(status));
            }

            //Filter by role
            if (rq.Role != UserRoles.Admin)
            {
                var role = rq.Role;
                queryObject.And(new OrderQueryObject.HasRole(role));
            }

            //Filter by current user name
            if (!string.IsNullOrWhiteSpace(rq.OwnerUserName) && rq.Role != UserRoles.Admin)
            {
                var userName = rq.OwnerUserName;
                queryObject.And(new OrderQueryObject.FilterByCurrentUserName(userName));
            }

            //Order by
            if (!rq.Sort.Any())
            {
                rq.Sort.Add(new SortItem {
                    FieldName = nameof(Order.IdentityKey)
                });
            }
            rq.Sort.ForEach(x => queryObject.AddOrderBy(x.FieldName, x.IsDescending));

            var result = await _genericRepo.SearchAsync(queryObject, rq.Pagination, x => x.Include(m => m.Product));

            return(result);
        }
Ejemplo n.º 6
0
 public IActionResult GetProduct([FromBody] SearchOrderModel searchOrderModel)
 {
     try
     {
         var productClass  = new ProductClass();
         var createProduct = productClass.GetProductModels(searchOrderModel.OrderId);
         var json          = JsonSerializer.Serialize(createProduct);
         return(Ok(json));
     }
     catch (Exception exception)
     {
         return(StatusCode(500, exception.Message));
     }
 }
Ejemplo n.º 7
0
        public async Task <IActionResult> Tracking(SearchOrderModel model)
        {
            string userId = null;

            if (this.User.IsInRole(GlobalConstants.SellerRoleName))
            {
                userId = this.User.GetId();
            }

            model.InputModel.UserId = userId;
            model.Orders            = await this.GetCustomersAsync(model.InputModel);

            return(this.View(model));
        }
Ejemplo n.º 8
0
 public IActionResult GetSubOrdersById([FromBody] SearchOrderModel orderModel)
 {
     try
     {
         var orderClass   = new OrderClass();
         var getSubOrders = orderClass.GetSubOrdersById(orderModel.OrderId);
         var json         = JsonSerializer.Serialize(getSubOrders, new JsonSerializerOptions()
         {
             IgnoreNullValues = true
         });
         return(Ok(json));
     }
     catch (Exception exception)
     {
         return(StatusCode(500, exception.Message));
     }
 }
Ejemplo n.º 9
0
        public async Task <IActionResult> Tracking()
        {
            string userId = null;

            if (this.User.IsInRole(GlobalConstants.SellerRoleName))
            {
                userId = this.User.GetId();
            }

            var model = new SearchOrderModel
            {
                Orders = await this.GetCustomersAsync(new SearchOrderInputModel
                {
                    UserId = userId,
                }),
            };

            return(this.View(model));
        }
Ejemplo n.º 10
0
        public ActionResult SearchOrders()
        {
            SearchOrderModel returnModel = new SearchOrderModel();

            returnModel.StoreOptions = Utility.GetStoresOptions(User, "All");

            returnModel.PaymentMethodOptions = Utility.GetPaymentMethodOptions("All");

            returnModel.PaymentStatusOptions = Utility.GetPaymentStatusOptions("All");

            returnModel.OrderStatusOptions = Utility.GetOrderStatusOptions("All");

            returnModel.SetSharedData(User);

            if (returnModel.Role == RoleTypes.SubAdmin)
            {
                returnModel.StoreId = (returnModel as BaseViewModel).StoreId;
            }

            return(PartialView("_SearchOrders", returnModel));
        }
Ejemplo n.º 11
0
        public ActionResult SearchOrderResults(SearchOrderModel model)
        {
            var response = AsyncHelpers.RunSync <JObject>(() => ApiCall.CallApi
                                                              ("api/Admin/SearchOrders", User, null, true, false, null,
                                                              "OrderStatusId=" + (model.OrderStatusId == 0 ? null : model.OrderStatusId - 1),
                                                              "PaymentStatusId=" + (model.PaymentStatusId == 0 ? null : model.PaymentStatusId - 1),
                                                              "PaymentMethodId=" + (model.PaymentMethodId == 0 ? null : model.PaymentMethodId - 1),
                                                              "StoreId=" + (model.StoreId == 0 ? null : model.StoreId),
                                                              "StartDate=" + (model.StartDate == DateTime.MinValue ? DateTime.Now : model.StartDate),
                                                              "EndDate=" + (model.EndDate == DateTime.MinValue ? DateTime.Now : model.EndDate)));

            SearchOrdersListViewModel returnModel = new SearchOrdersListViewModel();

            if (response is Error)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.InternalServerError, (response as Error).ErrorMessage));
            }
            else
            {
                returnModel = response.GetValue("Result").ToObject <SearchOrdersListViewModel>();
            }

            foreach (var item in returnModel.Orders)
            {
                item.CustomerName      = item.CustomerName == null ? "-" : item.CustomerName;
                item.OrderItemsComaSep = item.OrderItemsComaSep == null ? "-" : item.OrderItemsComaSep;
            }

            returnModel.OrderStatusOptions = Utility.GetOrderStatusOptions();

            foreach (var order in returnModel.Orders)
            {
                order.OrderStatus = order.OrderStatus + 1;
            }
            returnModel.SetSharedData(User);
            return(PartialView("_SearchOrderResults", returnModel));
        }
Ejemplo n.º 12
0
        public IHttpActionResult MyGigsList(SearchOrderModel viewModel)
        {
            bool success = false;
            var  message = "";
            var  model   = new List <MyGigModel>();

            if (!ModelState.IsValid)
            {
                var errors = ModelState.Where(x => x.Value.Errors.Count > 0).Select(x => new { x.Value.Errors }).FirstOrDefault();
                message = errors.Errors[0].ErrorMessage;
            }
            else
            {
                try
                {
                    if (viewModel.GigType == "Bidding")
                    {
                        var query = context.GetMyGigList(viewModel.UserId, viewModel.UserType, viewModel.GigType, viewModel.SearchKeyword == null ? "" : viewModel.SearchKeyword);
                        model = query.Select(x => new MyGigModel
                        {
                            ID                    = x.ID,
                            JobTitle              = x.JobTitle,
                            ProposalId            = x.ProposalId,
                            ReceivedBid           = x.ReceivedBid,
                            ServicePic            = File.Exists(System.Web.Hosting.HostingEnvironment.MapPath(x.ServicePic)) ? x.ServicePic : "/Content/images/services-bg.jpg",
                            CreatedDate           = x.UpdatedDate.ToString("MM/dd/yyyy HH:mm:ss"),
                            JobExpireDate         = Convert.ToDateTime(x.JobExpireDate).ToString("MM/dd/yyyy HH:mm:ss"),
                            CurrentProposalStatus = x.CurrentProposalStatus
                        }).OrderByDescending(x => x.ProposalId).ToList();
                        success = true;
                        message = "Get List";
                    }
                    if (viewModel.GigType == "Awarded")
                    {
                        var query = context.GetMyGigList(viewModel.UserId, viewModel.UserType, viewModel.GigType, viewModel.SearchKeyword == null ? "" : viewModel.SearchKeyword);
                        model = query.Select(x => new MyGigModel
                        {
                            ID                    = x.ID,
                            JobTitle              = x.JobTitle,
                            ProposalId            = x.ProposalId,
                            ReceivedBid           = x.ReceivedBid,
                            ServicePic            = File.Exists(System.Web.Hosting.HostingEnvironment.MapPath(x.ServicePic)) ? x.ServicePic : "/Content/images/services-bg.jpg",
                            CreatedDate           = x.UpdatedDate.ToString("MM/dd/yyyy HH:mm:ss"),
                            JobExpireDate         = Convert.ToDateTime(x.JobExpireDate).ToString("MM/dd/yyyy HH:mm:ss"),
                            CurrentProposalStatus = x.CurrentProposalStatus
                        }).OrderByDescending(x => x.ProposalId).ToList();
                        success = true;
                        message = "Get List";
                    }
                    if (viewModel.GigType == "Completed")
                    {
                        var query = context.GetMyGigList(viewModel.UserId, viewModel.UserType, viewModel.GigType, viewModel.SearchKeyword == null ? "" : viewModel.SearchKeyword);
                        model = query.Select(x => new MyGigModel
                        {
                            ID                    = x.ID,
                            JobTitle              = x.JobTitle,
                            ProposalId            = x.ProposalId,
                            ReceivedBid           = x.ReceivedBid,
                            ServicePic            = File.Exists(System.Web.Hosting.HostingEnvironment.MapPath(x.ServicePic)) ? x.ServicePic : "/Content/images/services-bg.jpg",
                            CreatedDate           = x.UpdatedDate.ToString("MM/dd/yyyy HH:mm:ss"),
                            JobExpireDate         = Convert.ToDateTime(x.JobExpireDate).ToString("MM/dd/yyyy HH:mm:ss"),
                            CurrentProposalStatus = x.CurrentProposalStatus
                        }).OrderByDescending(x => x.ProposalId).ToList();
                        success = true;
                        message = "Get List";
                    }
                }
                catch (Exception ex)
                {
                    message = ex.Message;
                }
            }
            return(Ok(new
            {
                Success = success,
                Message = message,
                Result = model
            }));
        }
 public IEnumerable <OrderViewModel> Search([FromQuery] SearchOrderModel model)
 {
     return(_orderService.SearchOrders(model.Term, model.UserId, model.OrderedStartOn, model.OrderedEndOn));
 }
Ejemplo n.º 14
0
 public ActionResult PagesData(SearchOrderModel searchOrder)
 {
     return(PartialView("_OrdersData", _orderRepository.GetOrders(searchOrder)));
 }