public ActionResult ListConsignments(DataSourceRequest command, AUConsignmentList model)
        {
            int consignmentid = 0;

            //string firstname = "Test";
            //string lastname = "";

            int consignorid = model.searchAUConsignorID;
            string desc = model.searchDesc;

            var consignments = _consignmentService.GetAllConsignments(
                consignorId: consignorid,
                consignmentId: consignmentid,
                desc: desc,
                pageIndex: 0,
                pageSize: 500);

            //pageIndex: command.Page - 1,
            //pageSize: command.PageSize);


            //TODO: THIS WILL NEED TO BE CHANGED WHEN YOU IMPLEMENT MORE THAN ONE CONSIGNOR PER CONSIGNMENT
            var gridModel = new DataSourceResult
            {
                Data = consignments.Select(x => new
                {
                    Id = x.Id, 
                    AUConsignorID = x.AUConsignorRecords.First().AUConsignorID, //TODO: make this a "primary" consignor select or coalesce all consignors
                    AUConsignmentID = x.AUConsignmentID,
                    ConsignmentDate = x.ConsignmentDate,
                    ConsignmentDesc = x.ConsignmentDesc
                }),
                Total = consignments.TotalCount
            };

            //var gridModel = new DataSourceResult();






            return Json(gridModel);

        }
        public ActionResult ManageConsignments()
        {
            //return View(); 
            AUConsignmentList listsearch = new AUConsignmentList();

            //if (consignorID != 0) { listsearch.searchAUConsignorID = consignorID;}

            return View("~/Views/AUConsignor/ManageConsignments.cshtml", listsearch); //not hit first time??
        }
        public ActionResult LotConsignmentSelectPopup(string selectedIds, int lotId, string btnIdToRefresh, string frmIdToRefresh, AUConsignmentList model)
        {
            ////TODO: Implement permissions
            ////if (!_permissionService.Authorize(StandardPermissionProvider.ManageProducts))
            ////    return AccessDeniedView();


            //var consignor = _consignorService.GetConsignorById(consignorId);
            //if (consignor == null || selectedIds == null)
            //{
            //    ErrorNotification("A major error occurred -consignor id or selected ids from ConsignorCustomerSelectPopup null. Please contact System Support");
            //    return RedirectToAction("ManageConsignors");
            //}

            ////TODO: Finish this - Need to get the lot info to ensure not already sold and unpublished
            //var ids = selectedIds
            //        .Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries)
            //        .Select(x => Convert.ToInt32(x))
            //        .ToArray();

            //var customer = _consignorService.GetCustomerById(ids[0]);

            //if (customer == null)
            //{
            //    ErrorNotification("A major error occurred - customer not found using vendor id from ConsignorCustomerSelectPopup null. Please contact System Support");
            //    return RedirectToAction("ManageConsignors");
            //}

            //consignor.CustomerID = customer.Id;
            //_consignorRepo.Update(consignor);


            //SuccessNotification("Customer associated to Consignor!!");  //seems to be nop admin convention

            ViewBag.RefreshPage = true;
            ViewBag.btnId = btnIdToRefresh;
            ViewBag.formId = frmIdToRefresh;
            return View("~/Views/AUConsignor/LotConsignmentSelectPopup.cshtml", model);
            ////return RedirectToAction("ListLots"); //TODO FIX THIS
        }
 public ActionResult ListOneConsignments(int consignorID = 0)
 {
     AUConsignmentList consignments = new AUConsignmentList();
     consignments.searchAUConsignorID = consignorID;
     return View("~/Views/AUConsignor/OneConsignorConsignments.cshtml", consignments);
 }
        public ActionResult LotConsignmentSelectPopup(int lotId) //may be zero if lot not created yet
        {
            //TODO: Permissions to associate Customer to Consignor
            //if (!_permissionService.Authorize(StandardPermissionProvider.ManageProducts))
            //    return View("~/Administration/Views/Security/AccessDenied.cshtml");

            var model = new AUConsignmentList();  //using same search model as ManageConsignments
            model.lotId = lotId; //??????

            //TODO: a vendor should not be able to see the consignor info or set the customer. Add and Set the indicator in the model
            //model.IsLoggedInAsVendor = _workContext.CurrentVendor != null;
            model.IsLoggedInAsVendor = false;
            //model.AUConsignorId = consignorId;

            return View("~/Views/AUConsignor/LotConsignmentSelectPopup.cshtml", model);
        }