Ejemplo n.º 1
0
        public ActionResult Index(ProfileBoxSearchModel search, int page = 1, int pageSize = 5, GridSortOptions sort = null)
        {
            var model = new ProfileBoxsModel();
            //model.ProfileBox = new ProfileBoxInfomationModel
            //{
            //    Name = DateTime.Now.ToString("ddMMyyyy_HH") + "_" + _workContext.User.UserName,
            //    UserName = _workContext.User.UserName
            //};

            Dictionary <string, string> profileTypes = _profileTypeService.GetAllTypes();

            ViewBag.ProfileType = WebUtility.ConvertDictionaryToSelectList(profileTypes, true);

            Dictionary <string, string> warehouses = _warehouseService.GetAllWarehouses();

            ViewBag.Warehouses = WebUtility.ConvertDictionaryToSelectList(warehouses, true);


            Dictionary <string, string> users = _userService.GetAllUsers();

            ViewBag.Users = WebUtility.ConvertDictionaryToSelectList(users, true);



            ViewBag.StatusList = WebUtility.ConvertEnumToSelectList <ABO.Core.ProfileBoxStatus>(true);
            model.SearchModel  = search;

            var data = _profileBoxService.Search(page, pageSize, search.ToCriteria <ProfileBoxSearchModel, ProfileBoxSearchCriteria>());

            model.Data = data.Select(x => x.ToModel <ProfileBoxGridModel>()).ToList();

            ViewBag.ShowAddButton = _workContext.User.WarehouseId;

            model.Pager = data.ToMvcPaging(model.Data);

            return(View(model));
        }
Ejemplo n.º 2
0
        public ActionResult Index(ProfileBoxSearchModel search)
        {
            try
            {
                var profileBoxes = _profileBoxService.Search(1, _webHelper.ExcelSheetMaxRows, search.ToCriteria <ProfileBoxSearchModel, ProfileBoxSearchCriteria>());

                var table = new DataTable();
                table.Columns.Add(_resourceManager.GetString("ProfileBox.Name"));
                table.Columns.Add(_resourceManager.GetString("ProfileBox.CreatedDate"));
                table.Columns.Add(_resourceManager.GetString("ProfileBox.UserID"));
                table.Columns.Add(_resourceManager.GetString("ProfileBox.WareHouse"));
                table.Columns.Add(_resourceManager.GetString("ProfileBox.BoxStatus2"));
                table.Columns.Add(_resourceManager.GetString("ProfileBox.AdaCount"));

                foreach (var box in profileBoxes)
                {
                    table.Rows.Add(new object[]
                    {
                        box.Name,
                        box.CreatedDate.ToString("dd/MM/yyyy"),
                        box.User.UserName,
                        box.Warehouse.WarehouseName,
                        box.Status.Name,
                        box.ADACount,
                    });
                }

                var excelData = _exportManager.ExportExcelFromDataTable(table, "ProfileBoxes", null);
                return(File(excelData, FileContentType.EXCEL, "ProfileBoxes.xlsx"));
            }
            catch (Exception ex)
            {
                ErrorNotification(_resourceManager.GetString("Error" + ex.Message));
                return(Redirect(Request.RawUrl));
            }
        }