/////////// <summary>
        /////////// Prepare category (simple) models
        /////////// </summary>
        /////////// <param name="rootCategoryId">Root category identifier</param>
        /////////// <param name="loadSubCategories">A value indicating whether subcategories should be loaded</param>
        /////////// <param name="allCategories">All available categories; pass null to load them internally</param>
        /////////// <returns>Category models</returns>
        ////////[NonAction]
        ////////protected virtual IList<AUCategorySimpleModel> PrepareCategorySimpleModels(int rootCategoryId,
        ////////    bool loadSubCategories = true, IList<Category> allCategories = null)
        ////////{
        ////////    var result = new List<AUCategorySimpleModel>();

        ////////    //little hack for performance optimization.
        ////////    //we know that this method is used to load top and left menu for categories.
        ////////    //it'll load all categories anyway.
        ////////    //so there's no need to invoke "GetAllCategoriesByParentCategoryId" multiple times (extra SQL commands) to load childs
        ////////    //so we load all categories at once
        ////////    //if you don't like this implementation if you can uncomment the line below (old behavior) and comment several next lines (before foreach)
        ////////    //var categories = _categoryService.GetAllCategoriesByParentCategoryId(rootCategoryId);
            
        ////////    //--original - pulled as no way possible to load up all Kelleher's categories
        ////////    //if (allCategories == null)
        ////////    //{
        ////////    //    //load categories if null passed
        ////////    //    //we implemeneted it this way for performance optimization - recursive iterations (below)
        ////////    //    //this way all categories are loaded only once
        ////////    //    allCategories = _categoryService.GetAllCategories();
        ////////    //}

        ////////    //--original - changed to get the high level sales
        ////////    //var categories = allCategories.Where(c => c.ParentCategoryId == rootCategoryId).ToList();

        ////////    var categories = allCategories.Where(c => c.ParentCategoryId == rootCategoryId).ToList();



        ////////    foreach (var category in categories)
        ////////    {
        ////////        var categoryModel = new AUCategorySimpleModel
        ////////        {
        ////////            Id = category.Id,
        ////////            Name = category.GetLocalized(x => x.Name),
        ////////            SeName = category.GetSeName(),
        ////////            IncludeInTopMenu = category.IncludeInTopMenu
        ////////        };

        ////////        //product number for each category
        ////////        if (_catalogSettings.ShowCategoryProductNumber)
        ////////        {
        ////////            string cacheKey = string.Format(ModelCacheEventConsumer.CATEGORY_NUMBER_OF_PRODUCTS_MODEL_KEY,
        ////////                string.Join(",", _workContext.CurrentCustomer.GetCustomerRoleIds()),
        ////////                _storeContext.CurrentStore.Id,
        ////////                category.Id);
        ////////            categoryModel.NumberOfProducts = _cacheManager.Get(cacheKey, () =>
        ////////            {
        ////////                var categoryIds = new List<int>();
        ////////                categoryIds.Add(category.Id);
        ////////                //include subcategories
        ////////                if (_catalogSettings.ShowCategoryProductNumberIncludingSubcategories)
        ////////                    categoryIds.AddRange(GetChildCategoryIds(category.Id));
        ////////                return _productService.GetCategoryProductNumber(categoryIds, _storeContext.CurrentStore.Id);
        ////////            });
        ////////        }

        ////////        if (loadSubCategories)
        ////////        {
        ////////            var subCategories = PrepareCategorySimpleModels(category.Id, loadSubCategories, allCategories);
        ////////            categoryModel.SubCategories.AddRange(subCategories);
        ////////        }
        ////////        result.Add(categoryModel);
        ////////    }

        ////////    return result;
        ////////}




        //-------------------------------------------------------------------------------------------
        //////[AvoidIfChildAction]
        //////public ActionResult EditCustomer(int ConsignorId = 0)
        //////{

        //////    AUConsignorRecord consignor = new AUConsignorRecord() { FirstName = "Test" };
        //////    if (ConsignorId > 0)
        //////    {
        //////        consignor = _consignorRepo.GetById(ConsignorId);
        //////    }


        //////    //try this!!   COMMENTED 03/23/16 TO AVOID THE WHOL INHERITANCE BULLSHIT
        //////    //return RedirectToAction("Edit", "AUConsignorAdmin", new { id = consignor.CustomerID, area = "Admin" });

        //////    return RedirectToAction("Edit", "Customer", new { id = consignor.CustomerID, area = "Admin" });

        //////    //comment for now
        //////    //if (!ControllerContext.IsChildAction)    
        //////    //{ return View(consignor); }
        //////    //else
        //////    //{ return PartialView(consignor); }

        //////}



        //--------------------------------------------------------------------------------------
        //////[AvoidIfChildAction]
        //////public ActionResult EditProduct(int Id = 0)
        //////{

            
        //////    //try this!!   COMMENTED 03/23/16 TO AVOID THE WHOL INHERITANCE BULLSHIT
        //////    //return RedirectToAction("Edit", "AUConsignorAdmin", new { id = consignor.CustomerID, area = "Admin" });

        //////    return RedirectToAction("Edit", "Product", new { id = Id, area = "Admin" });

        //////    //comment for now
        //////    //if (!ControllerContext.IsChildAction)   
        //////    //{ return View(consignor); }
        //////    //else
        //////    //{ return PartialView(consignor); }

        //////}





//----------------------------------------------------------------------------------------
        //////[HttpPost]
        //////public ActionResult ImportPhilatelicExcel()
        //////{
        //////    if (!_permissionService.Authorize(StandardPermissionProvider.ManageProducts))
        //////        //return AccessDeniedView();
        //////        //NJM: this view is in C:\Users\Nicholas\Documents\My Documents\NopCommerce_3_50\Presentation\Nop.Web\Administration\Views\Security\AccessDenied.cshtml
        //////        return View("~/Administration/Views/Security/AccessDenied.cshtml");

        //////    //a vendor cannot import products
        //////    if (_workContext.CurrentVendor != null)
        //////        //return AccessDeniedView();
        //////        return View("~/Administration/Views/Security/AccessDenied.cshtml");

        //////    try
        //////    {
        //////        var file = Request.Files["importphilatelicexcelfile"];
        //////        if (file != null && file.ContentLength > 0)
        //////        {
        //////           //Replace standard product import with philatelic import
        //////            //_importManager.ImportProductsFromXlsx(file.InputStream);
        //////            _collectibleimportService.ImportPhilatelicProductsFromXlsx(file.InputStream);
        //////        }
        //////        else
        //////        {
        //////            ErrorNotification(_localizationService.GetResource("Admin.Common.UploadFile"));
        //////            return RedirectToAction("ListLots"); //Added back when decided to used "Manage lots"
        //////            //return RedirectToAction("List", "Product"); // Redirect works cleanly - added when merged into NopCommerce "Manage Products"

        //////        }
        //////        SuccessNotification(_localizationService.GetResource("Plugins.Misc.AUConsignor.LotImportMsg"));
        //////        return RedirectToAction("ListLots"); //Added back when decided to used "Manage lots"
        //////        //return RedirectToAction("List", "Product"); // Redirect works cleanly - added when merged into NopCommerce "Manage Products"
        //////    }
        //////    catch (Exception exc)
        //////    {
        //////        ErrorNotification(exc);
        //////        return RedirectToAction("ListLots"); //Added back when decided to used "Manage lots"
        //////        //return RedirectToAction("List", "Product"); // Redirect works cleanly - added when merged into NopCommerce "Manage Products"
        //////    }

        //////}

        //----------------------------------------------------------------------------------------
        ////////TODO: don't think this is used - need to change others so uses list method and doesn't list all first time in
        ////// public ActionResult ManageLots()
        //////{
        //////    //return View();
        //////    return View("~/Views/AUConsignor/ManageLots.cshtml"); //not hit first time??
        //////}


        //---------------------------------------------------------------------------------
        //////public ActionResult Configure()
        //////{


        //////    //load settings for a chosen store scope
        //////    var storeScope = this.GetActiveStoreScopeConfiguration(_storeService, _workContext);
        //////    var AUConsignorSettings = _settings.LoadSetting<Nop.Plugin.Misc.AUConsignor.Domain.AUConsignorSettings>(storeScope);


        //////    var model = new Nop.Plugin.Misc.AUConsignor.Domain.AUConfigurationRecord();
        //////    model.AllowStoreProductInquiries = AUConsignorSettings.AllowStoreProductInquiries;
        //////    //model.StoreIsAuctionSite = AUConsignorSettings.StoreIsAuctionSite;  *DEPRECATE*
        //////    model.StoreTypeId = AUConsignorSettings.StoreTypeId;



        //////    model.AvailableStoreTypes.Add(new SelectListItem { Text = _localizationService.GetResource("Plugins.Misc.AUConsignor.StoreType.InternetLiveAuction"), Value = AUStoreTypeEnum.InternetLiveAuction.ToString() });
        //////    model.AvailableStoreTypes.Add(new SelectListItem { Text = _localizationService.GetResource("Plugins.Misc.AUConsignor.StoreType.InternetAuction"), Value = AUStoreTypeEnum.InternetAuction.ToString() });
        //////    model.AvailableStoreTypes.Add(new SelectListItem { Text = _localizationService.GetResource("Plugins.Misc.AUConsignor.StoreType.MixedRetail"), Value = AUStoreTypeEnum.MixedRetail.ToString() });
        //////    model.AvailableStoreTypes.Add(new SelectListItem { Text = _localizationService.GetResource("Plugins.Misc.AUConsignor.StoreType.OriginalRetail"), Value = AUStoreTypeEnum.OriginalRetail.ToString() });




        //////    //TODO: Need to test this store setting shit out
        //////    model.ActiveStoreScopeConfiguration = storeScope;
        //////    if (storeScope > 0)
        //////    {
        //////        model.AllowStoreProductInquiries_OverrideForStore = _settings.SettingExists(AUConsignorSettings, x => x.AllowStoreProductInquiries, storeScope);
        //////        // model.StoreIsAuctionSite_OverrideForStore = _settings.SettingExists(AUConsignorSettings, x => x.StoreIsAuctionSite, storeScope);   *DEPRECATE*
        //////        model.StoreTypeId_OverrideForStore = _settings.SettingExists(AUConsignorSettings, x => x.StoreTypeId, storeScope);
        //////    }

        //////    //return View();

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

        //------------------------------------------------------------------------------------
        //////[HttpPost]
        //////public ActionResult PublishSelected(string selectedIds)
        //////{
        //////    //TODO: Implement permissions
        //////    //if (!_permissionService.Authorize(StandardPermissionProvider.ManageProducts))
        //////    //    return AccessDeniedView();

        //////    //TODO: Finish this - Need to get the lot info to ensure not already sold and unpublished
        //////    var lots = new List<AULotEdit>();
        //////    if (selectedIds != null)
        //////    {
        //////       lots.AddRange(_consignorService.GetLotsByProductIds(selectedIds));
        //////    }

        //////    //uncomment in a minute
        //////    var products = new List<Product>();
        //////    if (selectedIds != null)
        //////    {
        //////        var ids = selectedIds
        //////            .Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries)
        //////            .Select(x => Convert.ToInt32(x))
        //////            .ToArray();
        //////        products.AddRange(_productService.GetProductsByIds(ids));
        //////        //TODO: YOU NEED TO MAKE ANOTHER SERVICE CALL TO GET EXPANDED AUCOMBLOTPROC
        //////    }



        //////    //a vendor should have access only to his products
        //////    if (_workContext.CurrentVendor != null)
        //////    {
        //////        products = products.Where(p => p.VendorId == _workContext.CurrentVendor.Id).ToList();
        //////    }


        //////    _consignorService.PublishSelectedProducts(products);


        //////    SuccessNotification("Lots were published!!");  //seems to be nop admin convention

        //////    return RedirectToAction("ListLots"); // Added back when decided to route to "Manage Lots"
        //////    //return RedirectToAction("List", "Product"); // Redirect works cleanly - used when merged into NopCommerce "Manage Products"

        //////}

        //----------------------------------------------------------------------------------------
        //////[HttpPost]
        //////public ActionResult UnPublishSelected(string selectedIds)
        //////{
        //////    //TODO: Implement permissions
        //////    //if (!_permissionService.Authorize(StandardPermissionProvider.ManageProducts))
        //////    //    return AccessDeniedView();

        //////    //TODO: Finish this - Need to get the lot info to ensure not already sold and unpublished
        //////    var lots = new List<AULotEdit>();
        //////    if (selectedIds != null)
        //////    {
        //////        lots.AddRange(_consignorService.GetLotsByProductIds(selectedIds));
        //////    }

        //////    //uncomment in a minute
        //////    var products = new List<Product>();
        //////    if (selectedIds != null)
        //////    {
        //////        var ids = selectedIds
        //////            .Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries)
        //////            .Select(x => Convert.ToInt32(x))
        //////            .ToArray();
        //////        products.AddRange(_productService.GetProductsByIds(ids));
        //////        //TODO: YOU NEED TO MAKE ANOTHER SERVICE CALL TO GET EXPANDED AUCOMBLOTPROC
        //////    }



        //////    //a vendor should have access only to his products
        //////    if (_workContext.CurrentVendor != null)
        //////    {
        //////        products = products.Where(p => p.VendorId == _workContext.CurrentVendor.Id).ToList();
        //////    }


        //////    int ret = _consignorService.UnPublishSelectedProducts(products);

        //////    if (ret == 0)
        //////    {
        //////        SuccessNotification("Lots were Unpublished!!");  
        //////    }
        //////    else
        //////    {
        //////        SuccessNotification("Some lots were not Unpublished because 1) there are active bids or 2) the lot was sold or 3) the lots is already unpublished!!");  
        //////    }
            
        //////     return RedirectToAction("ListLots"); // Added back in when decided to use "Manage Lots"
        //////    //return RedirectToAction("List", "Product"); // Redirect works cleanly - used when merged into NopCommerce "Manage Products"


        //////}



        //------------------------------------------------------------------------------------------
        //////[HttpPost]
        //////[AdminAuthorize]
        //////[ChildActionOnly]
        //////public ActionResult Configure(Nop.Plugin.Misc.AUConsignor.Domain.AUConfigurationRecord model)
        //////{
        //////    if (!ModelState.IsValid)
        //////        return Configure();

        //////    //load settings for a chosen store scope
        //////    var storeScope = this.GetActiveStoreScopeConfiguration(_storeService, _workContext);
        //////    var AUConsignorSettings = _settings.LoadSetting<Nop.Plugin.Misc.AUConsignor.Domain.AUConsignorSettings>(storeScope);

        //////    //save settings
        //////    AUConsignorSettings.AllowStoreProductInquiries = model.AllowStoreProductInquiries;
        //////    // AUConsignorSettings.StoreIsAuctionSite = model.StoreIsAuctionSite;   *DEPRECATE*
        //////    AUConsignorSettings.StoreTypeId = model.StoreTypeId;

        //////    //purchaseOrderPaymentSettings.AdditionalFeePercentage = model.AdditionalFeePercentage;
        //////    //purchaseOrderPaymentSettings.ShippableProductRequired = model.ShippableProductRequired;

        //////    /* We do not clear cache after each setting update.
        //////     * This behavior can increase performance because cached settings will not be cleared 
        //////     * and loaded from database after each update */
        //////    if (model.AllowStoreProductInquiries_OverrideForStore || storeScope == 0)
        //////        _settings.SaveSetting(AUConsignorSettings, x => x.AllowStoreProductInquiries, storeScope, false);
        //////    else if (storeScope > 0)
        //////        _settings.DeleteSetting(AUConsignorSettings, x => x.AllowStoreProductInquiries, storeScope);

        //////    // *DEPRECATE*
        //////    //if (model.StoreIsAuctionSite_OverrideForStore || storeScope == 0)
        //////    //    _settings.SaveSetting(AUConsignorSettings, x => x.StoreIsAuctionSite, storeScope, false);
        //////    //else if (storeScope > 0)
        //////    //    _settings.DeleteSetting(AUConsignorSettings, x => x.StoreIsAuctionSite, storeScope);


        //////    if (model.StoreTypeId_OverrideForStore || storeScope == 0)
        //////        _settings.SaveSetting(AUConsignorSettings, x => x.StoreTypeId, storeScope, false);
        //////    else if (storeScope > 0)
        //////        _settings.DeleteSetting(AUConsignorSettings, x => x.StoreTypeId, storeScope);



        //////    //if (model.AdditionalFeePercentage_OverrideForStore || storeScope == 0)
        //////    //    _settingService.SaveSetting(purchaseOrderPaymentSettings, x => x.AdditionalFeePercentage, storeScope, false);
        //////    //else if (storeScope > 0)
        //////    //    _settingService.DeleteSetting(purchaseOrderPaymentSettings, x => x.AdditionalFeePercentage, storeScope);

        //////    //if (model.ShippableProductRequired_OverrideForStore || storeScope == 0)
        //////    //    _settingService.SaveSetting(purchaseOrderPaymentSettings, x => x.ShippableProductRequired, storeScope, false);
        //////    //else if (storeScope > 0)
        //////    //    _settingService.DeleteSetting(purchaseOrderPaymentSettings, x => x.ShippableProductRequired, storeScope);

        //////    //now clear settings cache
        //////    _settings.ClearCache();

        //////    SuccessNotification(_localizationService.GetResource("Admin.Plugins.Saved"));

        //////    return Configure();
        //////}




        public ActionResult CompareLastLotBidChange(int productId, DateTime? LastBidDateTime)
        {

            AULotLastBidChangeRecord lotchange = _lotService.GetLotLastBidChangeByProductId(productId);

            //true means dates the same, false means dates different so refresh the div
            ///Need allowget if using with get call (i.e. from ajax bid post)
            if (lotchange.LastBidChangeDT.IsNullOrDefault() && LastBidDateTime.IsNullOrDefault())
               return Json(new {result = true, newdate = lotchange.LastBidChangeDT}, JsonRequestBehavior.AllowGet);   
            else
                if (lotchange.LastBidChangeDT.IsNullOrDefault() && !LastBidDateTime.IsNullOrDefault())
                    return Json(new { result = false, newdate = lotchange.LastBidChangeDT }, JsonRequestBehavior.AllowGet);   
                else
                    if (lotchange.LastBidChangeDT == LastBidDateTime)
                        return Json(new {result = true, newdate = lotchange.LastBidChangeDT}, JsonRequestBehavior.AllowGet);   
                    else
                        return Json(new { result = false, newdate = lotchange.LastBidChangeDT }, JsonRequestBehavior.AllowGet);  

        }
Exemplo n.º 2
0
        public DateRange GetDateTimeRange(DateTime? referenceMoment)
        {
            DateTime refMoment = referenceMoment.IsNullOrDefault() ? (this.Unit.IsMomentInTime() ? DateTime.UtcNow : DateTime.Now) : referenceMoment.Value;

            DateTime? start = null, end = null;

            switch(this.Direction)
            {
                case Timeline.EntireCurrentOrSpecified:
                    start = refMoment.StartOf(this.Unit);
                    end = refMoment.EndOf(this.Unit);
                    break;
                case Timeline.ToDateOrTillSpecified:
                    start = refMoment.StartOf(this.Unit);
                    end = refMoment; // refMoment.EndOf(TimeUnits.Day);
                    break;
                case Timeline.Past:
                    end = refMoment;
                    start = this.Unit == TimeUnits.Eternity ? (DateTime?)null : end.Value.Add(-(int)this.UnitCount, this.Unit);
                    break;
                case Timeline.Future:
                    start = refMoment;
                    end = this.Unit == TimeUnits.Eternity ? (DateTime?)null : start.Value.Add((int)this.UnitCount, this.Unit);
                    break;
                case Timeline.PreviousExcludingCurrent:
                    end = refMoment.StartOf(this.Unit);
                    start = end.Value.Add(-(int)this.UnitCount, this.Unit);
                    end = end.Value.PreviousMoment();
                    break;
                case Timeline.NextExcludingCurrent:
                    start = refMoment.StartOf(this.Unit).Add(1, this.Unit);
                    end = start.Value.Add((int)this.UnitCount, this.Unit);
                    break;
            }

            DateRange range = new DateRange(start, end);
            return range;
        }