public ActionResult CreateUpdateConsignment(AUCombConsignorConsignment r2)
        {
            if (ModelState.IsValid)
            {
                AUConsignmentRecord consignment = _consignmentRepo.GetById(r2.AUConsignmentRecord.AUConsignmentID);

                //DEBUG TO SEE IF r1 IS AVAILABLE
                //TRY THIS WAY FIRST - NOT SURE BECAUSE MIGHT BE ABLE TO USE r1
                //MIGHT BE BEST ANYWAY TO ENSURE CORD STILL THERE
                //no  good !! could not instantiate
                //AUConsignorRecord consignor = _consignorRepo.GetById(r1.AUConsignorID);

                //string x = "not there";

                //if (RouteData.Values["ConsignmentId"] != null)
                //{
                //    x = RouteData.Values["ConsignmentId"].ToString();
                //}

                //if (consignor == null)
                //{
                //    //place error handling here
                //}

                if (consignment == null)
                {

                    //this worked but trying after insert
                    //AUConsignorConsignmentRecord testc = new AUConsignorConsignmentRecord();
                    //testc.AUConsignorID = 1;
                    ////testc.AUConsignmentID = 1;
                    //testc.AUConsignmentID = r2.AUConsignmentID; //already known?
                    //testc.Term = "F**k";
                    //r2.AUConsignorRecords.Add(testc);

                    //no good - can't update 2 entities
                    //r2.AUConsignmentRecord.CreatedOnDT = System.DateTime.UtcNow;
                    //r2.AUConsignmentRecord.UpdatedOnDT = System.DateTime.UtcNow;
                    //_combinedRepo.Insert(r2);

                    //try this first
                    var CurrentCustomer = _authenticationService.GetAuthenticatedCustomer();
                    r2.AUConsignmentRecord.CreatedBy = CurrentCustomer.Username;
                    r2.AUConsignmentRecord.UpdatedBy = CurrentCustomer.Username;
                    r2.AUConsignmentRecord.CreatedOnDT = System.DateTime.UtcNow;
                    r2.AUConsignmentRecord.UpdatedOnDT = System.DateTime.UtcNow;
                    _consignmentRepo.Insert(r2.AUConsignmentRecord);

                    //try this second
                    //AUConsignmentRecord consignment2 = new AUConsignmentRecord() { ConsignmentDesc = "Test" };
                    //consignment2.CreatedOnDT = System.DateTime.UtcNow;
                    //consignment2.UpdatedOnDT = System.DateTime.UtcNow;
                    //consignment2.ConsignmentDate = r2.AUConsignmentRecord.ConsignmentDate;
                    //consignment2.ConsignmentDesc = r2.AUConsignmentRecord.ConsignmentDesc;
                    //_consignmentRepo.Insert(consignment2);



                    /*
                    consignment.ConsignmentDate = r2.AUConsignmentRecord.ConsignmentDate;
                    consignment.ConsignmentDesc = r2.AUConsignmentRecord.ConsignmentDesc;
                    _consignmentRepo.Insert(consignment);
                    */


                    //try 1
                    AUConsignorConsignmentRecord testc = new AUConsignorConsignmentRecord();
                    testc.AUConsignmentID = r2.AUConsignmentRecord.AUConsignmentID;
                    testc.AUConsignorID = r2.AUConsignorRecord.AUConsignorID;
                    testc.Term = "Help!";
                    r2.AUConsignmentRecord.AUConsignorRecords.Add(testc);
                    _consignmentRepo.Update(r2.AUConsignmentRecord);

                    ////try 2
                    //AUConsignorConsignmentRecord testc = new AUConsignorConsignmentRecord();
                    //testc.AUConsignmentID = consignment2.AUConsignmentID;
                    //testc.AUConsignorID = r2.AUConsignorRecord.AUConsignorID;
                    //testc.Term = "Help!";
                    //consignment2.AUConsignorRecords.Add(testc);
                    //_consignmentRepo.Update(consignment2);



                    //var toUpdate = r2.AUConsignorRecords.First();
                    //toUpdate.AUConsignmentID = r2.AUConsignmentID;
                    //_consignmentRepo.Update(r2);

                    /*   worked
                    //fails because trying to insert AUConsignor again
                    AUConsignorConsignmentRecord testc = new AUConsignorConsignmentRecord();
                    //AUConsignmentRecord consignment2 = _consignmentRepo.GetById(r2.AUConsignmentID);
                    //testc.AUConsignorID = 1; WORKED
                    testc.AUConsignorID = consignor.AUConsignorID;
                    testc.AUConsignmentID = r2.AUConsignmentID;
                    testc.Term = "F**k";
                    r2.AUConsignorRecords.Add(testc);
                    _consignmentRepo.Update(r2);
                    */

                    //No Good - tried to insert AUConsignor again
                    //AUcc.AUConsignorID = 1;
                    //AUcc.AUConsignmentID = r2.AUConsignmentID;
                    //_consignorconsignmentRepo.Insert(AUcc);




                    //test shit out
                    //AUConsignorRecord c2 = new AUConsignorRecord();
                    //c2.LastName = "consignor Last Name";
                    //c2.AUConsignorID = 1;

                    //**************************************
                    //can only insert the same type passed in
                    //this is f*****g up consignment id for some reason
                    //*************************************************
                    //AUConsignmentRecord c2 = new AUConsignmentRecord();
                    //c2.AUConsignmentID = 99;
                    //c2.ConsignmentDesc = "This is the first internally generated consignment";
                    //_consignmentRepo.Insert(c2);



                    SuccessNotification("Consignment Created Successfully!");
                    return RedirectToRoute(new
                    {
                        Action = "CreateUpdateConsignment",
                        Controller = "AUConsignor",
                        ConsignorId = r2.AUConsignorRecord.AUConsignorID,
                        ConsignmentId = r2.AUConsignmentRecord.AUConsignmentID
                    });
                }
                else
                {

                    //use latest data in consignment rather that stale R2
                    var CurrentCustomer = _authenticationService.GetAuthenticatedCustomer();
                    consignment.UpdatedBy = CurrentCustomer.Username;
                    consignment.UpdatedOnDT = System.DateTime.UtcNow;
                    consignment.ConsignmentDate = r2.AUConsignmentRecord.ConsignmentDate;
                    consignment.ConsignmentDesc = r2.AUConsignmentRecord.ConsignmentDesc;


                    //System.DateTime? cDate = null;
                    //try
                    //{
                    //    cDate = new DateTime(model.DateOfBirthYear.Value, model.DateOfBirthMonth.Value, model.DateOfBirthDay.Value);
                    //}
                    //catch { }


                    r2.AUConsignmentRecord.UpdatedOnDT = consignment.UpdatedOnDT;
                    r2.AUConsignmentRecord.UpdatedBy = consignment.UpdatedBy;

                    //test
                    //AUConsignorRecord c2 = new AUConsignorRecord();
                    //c2.LastName = "consignor Last Name";
                    //c2.AUConsignorID = 1;

                    //consignment.AUConsignorRecords.Add(c2);
                    //ViewBag.RowsAffected = db.Database.ExecuteSqlCommand("UPDATE Course SET Credits = Credits * {0}", multiplier);


                    _consignmentRepo.Update(consignment);

                    //can only insert the same type passed in
                    //AUConsignmentRecord c2 = new AUConsignmentRecord();
                    //c2.AUConsignmentID = 99;
                    //c2.ConsignmentDesc = "This is the second updated description";
                    //_consignmentRepo.Update(c2);


                    //AUConsignorRecord c2 = new AUConsignorRecord();
                    //c2.LastName = "consignor New Last Name";
                    //c2.AUConsignorID = 1;
                    //_consignmentRepo.Insert();



                    _cacheManager.Clear();
                    SuccessNotification("Changed Saved!");
                    //return View(consignment); //now with customer view engine
                    return View("~/Views/AUConsignor/CreateUpdateConsignment.cshtml", r2); //not hit first time??
                    //return View("~/Plugins/Widgets.PromoSlider/Views/PromoSlider/CreateUpdatePromoSlider.cshtml", slider);
                }
            }
            else
            {
                //invalid model will show "default" error messages driven by record annotation/decorations
                var errors = ModelState.Values.SelectMany(v => v.Errors);
                return View("~/Views/AUConsignor/CreateUpdateConsignment.cshtml", r2);
                //return View();
                //return View("~/Views/PromoSlider/CreateUpdatePromoSlider.cshtml"); //not hit first time?
                //return View("~/Plugins/Widgets.PromoSlider/Views/PromoSlider/CreateUpdatePromoSlider.cshtml");
            }
        }
         public ActionResult ConsignmentFileUpdate(AUCombConsignorConsignment.ConsignmentFileModel model)
         {
             //TODO: permissions fo change file properties
             //if (!_permissionService.Authorize(StandardPermissionProvider.ManageProducts))
             //    return AccessDeniedView();

             var consignmentFile = _fileService.GetConsignmentFileById(model.Id);
             if (consignmentFile == null)
                 throw new ArgumentException("No consignment file found with the specified id");

             //TODO: a vendor should have access only to his products
             //see C:\Users\Nicholas\Documents\My Documents\NopCommerce\Libraries\Nop.Services\Catalog\ProductService.cs
             //if (_workContext.CurrentVendor != null)
             //{
             //    var product = _productService.GetProductById(productPicture.ProductId);
             //    if (product != null && product.VendorId != _workContext.CurrentVendor.Id)
             //    {
             //        return Content("This is not your product");
             //    }
             //}

             consignmentFile.DisplayOrder = model.DisplayOrder;
             _fileService.UpdateConsignmentFile(consignmentFile);

             var file = _fileService.GetFileById(consignmentFile.AUFileID);
             if (file == null)
                 throw new ArgumentException("No file found with the specified id");

             _fileService.UpdateFile(file.Id,
                 _fileService.LoadFileBinary(file),
                 file.MimeType,
                 //picture.SeoFilename,
                 model.OverrideAltAttribute,
                 model.OverrideTitleAttribute);

             return new NullJsonResult();
         }
        public ActionResult CreateUpdateConsignment(int ConsignorId = 0, int ConsignmentId = 0)
        {

            AUCombConsignorConsignment combined = new AUCombConsignorConsignment();


            if (ConsignmentId > 0)
            {
                combined.AUConsignmentRecord = _consignmentRepo.GetById(ConsignmentId);
                //consignment = _consignmentRepo.GetById(ConsignmentId);
            }
            else
            {
                //need to do this to make sure model is valid for ADD
                combined.AUConsignmentRecord = new AUConsignmentRecord();
                combined.AUConsignmentRecord.AUConsignmentID = 0; //set this because kick model invalid in POST otherwise
            }

            //this indicates it came from the createupdate consignor or manage consignors
            if (ConsignorId > 0)
            {
                combined.AUConsignorRecord = _consignorRepo.GetById(ConsignorId);
            }

            return View("~/Views/AUConsignor/CreateUpdateConsignment.cshtml", combined); //worked first time null

        }