public async Task <IActionResult> GoToId(MerchandiseReturnListModel model)
        {
            if (model.GoDirectlyToId == null)
            {
                return(RedirectToAction("List", "MerchandiseReturn"));
            }

            int.TryParse(model.GoDirectlyToId, out var id);

            //try to load a product entity
            var merchandiseReturn = await _merchandiseReturnService.GetMerchandiseReturnById(id);

            if (merchandiseReturn == null)
            {
                //not found
                return(RedirectToAction("List", "MerchandiseReturn"));
            }

            if (await _groupService.IsStaff(_workContext.CurrentCustomer) && merchandiseReturn.StoreId != _workContext.CurrentCustomer.StaffStoreId)
            {
                return(RedirectToAction("List", "MerchandiseReturn"));
            }

            return(RedirectToAction("Edit", "MerchandiseReturn", new { id = merchandiseReturn.Id }));
        }
Esempio n. 2
0
        public virtual MerchandiseReturnListModel PrepareReturnReqestListModel()
        {
            var model = new MerchandiseReturnListModel
            {
                //Merchandise return status
                MerchandiseReturnStatus = MerchandiseReturnStatus.Pending.ToSelectList(_translationService, _workContext, false).ToList()
            };

            model.MerchandiseReturnStatus.Insert(0, new SelectListItem {
                Text = _translationService.GetResource("Admin.Common.All"), Value = "-1"
            });

            return(model);
        }
        public async Task <IActionResult> List(DataSourceRequest command, MerchandiseReturnListModel model)
        {
            if (await _groupService.IsStaff(_workContext.CurrentCustomer))
            {
                model.StoreId = _workContext.CurrentCustomer.StaffStoreId;
            }
            var merchandiseReturnModels = await _merchandiseReturnViewModelService.PrepareMerchandiseReturnModel(model, command.Page, command.PageSize);

            var gridModel = new DataSourceResult
            {
                Data  = merchandiseReturnModels.merchandiseReturnModels,
                Total = merchandiseReturnModels.totalCount,
            };

            return(Json(gridModel));
        }
Esempio n. 4
0
        public virtual async Task <(IList <MerchandiseReturnModel> merchandiseReturnModels, int totalCount)> PrepareMerchandiseReturnModel(MerchandiseReturnListModel model, int pageIndex, int pageSize)
        {
            string customerId = string.Empty;

            if (!string.IsNullOrEmpty(model.SearchCustomerEmail))
            {
                var customer = await _customerService.GetCustomerByEmail(model.SearchCustomerEmail.ToLowerInvariant());

                if (customer != null)
                {
                    customerId = customer.Id;
                }
                else
                {
                    customerId = "00000000-0000-0000-0000-000000000000";
                }
            }
            DateTime?startDateValue = (model.StartDate == null) ? null
                : (DateTime?)_dateTimeService.ConvertToUtcTime(model.StartDate.Value, _dateTimeService.CurrentTimeZone);

            DateTime?endDateValue = (model.EndDate == null) ? null
                : (DateTime?)_dateTimeService.ConvertToUtcTime(model.EndDate.Value, _dateTimeService.CurrentTimeZone);

            var merchandiseReturns = await _merchandiseReturnService.SearchMerchandiseReturns(model.StoreId,
                                                                                              customerId,
                                                                                              "",
                                                                                              _workContext.CurrentVendor?.Id,
                                                                                              "",
                                                                                              (model.SearchMerchandiseReturnStatusId >= 0 ? (MerchandiseReturnStatus?)model.SearchMerchandiseReturnStatusId : null),
                                                                                              pageIndex - 1,
                                                                                              pageSize,
                                                                                              startDateValue,
                                                                                              endDateValue);

            var merchandiseReturnModels = new List <MerchandiseReturnModel>();

            foreach (var rr in merchandiseReturns)
            {
                var rrmodel = new MerchandiseReturnModel();
                merchandiseReturnModels.Add(await PrepareMerchandiseReturnModel(rrmodel, rr, true));
            }
            return(merchandiseReturnModels, merchandiseReturns.TotalCount);
        }