Exemplo n.º 1
0
        public async Task <OrderLimitListModel> PrepareOrderLimitListModel(OrderLimitSearchModel searchModel)
        {
            if (searchModel == null)
            {
                throw new ArgumentNullException(nameof(searchModel));
            }

            var orderLimits = await _orderLimitService.GetOrderLimitsAsync(
                storeIds : searchModel.SelectedStoreIds.ToArray(),
                pageIndex : searchModel.Page - 1,
                pageSize : searchModel.PageSize);

            var model = new OrderLimitListModel
            {
                Data = orderLimits.Select(orderLimit =>
                {
                    var orderLimitsModel = orderLimit.ToModel <OrderLimitModel>();

                    orderLimitsModel.DeliveryPerWeek = orderLimit.P_DeliveryPerWeek;
                    orderLimitsModel.Safety          = orderLimit.P_Safety;
                    orderLimitsModel.InventoryCycle  = orderLimit.P_InventoryCycle;
                    orderLimitsModel.OrderRatio      = orderLimit.P_OrderRatio;
                    orderLimitsModel.MinDays         = (int)orderLimit.P_MinDays;
                    orderLimitsModel.MaxDays         = (int)orderLimit.P_MaxDays;
                    orderLimitsModel.FaceQty         = (int)orderLimit.P_FaceQty;

                    //var storeName = _storeService.GetStoreById(orderLimit.P_BranchNo);
                    //orderLimitsModel.StoreName = orderLimit.P_BranchNo + " - " + storeName.P_Name;
                    orderLimitsModel.CreatedOn        = _dateTimeHelper.ConvertToUserTime(orderLimit.CreatedOnUtc, DateTimeKind.Utc);
                    orderLimitsModel.LastActivityDate = _dateTimeHelper.ConvertToUserTime(orderLimit.ModifiedOnUtc.GetValueOrDefault(DateTime.UtcNow), DateTimeKind.Utc);

                    return(orderLimitsModel);
                }),
                Total = orderLimits.TotalCount
            };

            // sort
            if (searchModel.Sort != null && searchModel.Sort.Any())
            {
                foreach (var s in searchModel.Sort)
                {
                    model.Data = await model.Data.Sort(s.Field, s.Dir);
                }
            }

            // filter
            if (searchModel.Filter != null && searchModel.Filter.Filters != null && searchModel.Filter.Filters.Any())
            {
                var filter = searchModel.Filter;
                model.Data = await model.Data.Filter(filter);

                model.Total = model.Data.Count();
            }

            return(model);
        }
Exemplo n.º 2
0
        public async Task <IActionResult> OrderLimitList(OrderLimitSearchModel searchModel)
        {
            if (!await _permissionService.AuthorizeAsync(StandardPermissionProvider.ManageOrderLimit))
            {
                return(AccessDeniedKendoGridJson());
            }

            var model = await _orderLimitModelFactory.PrepareOrderLimitListModel(searchModel);

            return(Json(model));
        }
Exemplo n.º 3
0
        public async Task <OrderLimitSearchModel> PrepareOrderLimitSearchModel(OrderLimitSearchModel searchModel)
        {
            if (searchModel == null)
            {
                throw new ArgumentNullException(nameof(searchModel));
            }

            //prepare page parameters
            searchModel.SetGridPageSize();

            var stores = await _storeService.GetStores();

            searchModel.AvailableStores = stores.Select(store => new SelectListItem
            {
                Text  = store.P_BranchNo.ToString() + " - " + store.P_Name,
                Value = store.P_BranchNo.ToString()
            }).ToList();

            return(await Task.FromResult(searchModel));
        }