public ActionResult CreateLotFinderFees(AUCombLotFinderFees combfees) { if (ModelState.IsValid) { AUFinderFeesRecord fee = new AUFinderFeesRecord(); //fee = _finderfeesRepo.GetById(combfees.AUFinderFeesRecord.AUFinderFeesID); //if (fee == null) //{ fee.AUEntityID = combfees.AULotID; fee.AUEntityType = "AULot"; fee.CustomerID = combfees.AUFinderFeesRecord.CustomerID; fee.DisplayOrder = 1; fee.FinderFeeAmt = combfees.AUFinderFeesRecord.FinderFeeAmt; fee.FinderFeePct = combfees.AUFinderFeesRecord.FinderFeePct; _finderfeesRepo.Insert(fee); SuccessNotification("Finder Fee Created Successfully!"); return RedirectToRoute(new { Action = "Edit", Controller = "Product", //ConsignorId = r2.AUConsignorRecord.AUConsignorID, id = combfees.ProductID }); //} //else //{ // throw new NopException("Finder Fee already exists! Please notify Administrator"); // //return View("~/Views/AUConsignor/CreateUpdateConsignmentFinderFees.cshtml", combfees); //not hit first time?? //} } else { //invalid model will show "default" error messages driven by record annotation/decorations //var errors = ModelState.Values.SelectMany(v => v.Errors); ErrorNotification("Finder Fee Not Created - Model has errors! Please notify administrator."); return View("~/Views/AUConsignor/CreateUpdateLotFinderFees.cshtml", combfees); //return View(); //return View("~/Views/PromoSlider/CreateUpdatePromoSlider.cshtml"); //not hit first time? //return View("~/Plugins/Widgets.PromoSlider/Views/PromoSlider/CreateUpdatePromoSlider.cshtml"); } }
public ActionResult CreateUpdateLotFinderFees(int id = 0) //id = Product Id { AUCombLotFinderFees lotfees = new AUCombLotFinderFees(); if (id > 0) { //consfees.AUConsignmentRecord = _consignmentRepo.GetById(ConsignmentId); var product = _productService.GetProductById(id); lotfees.ProductID = product.Id; lotfees.Name = product.Name; lotfees.ShortDescription = product.ShortDescription; var lot = _consignorService.GetLotByProductId(id); if (lot != null) { lotfees.AULotID = lot.AULotID; } else { lotfees.AULotID = 0; } } else { throw new NopException("No LotId provided - please notify system aministrator"); } //need to do this to make sure model is valid for ADD lotfees.AUFinderFeesRecord = new AUFinderFeesRecord(); lotfees.AUFinderFeesRecord.AUFinderFeesID = 0; //set this because kick model invalid in POST otherwise return View("~/Views/AUConsignor/CreateUpdateLotFinderFees.cshtml", lotfees); //worked first time null }
//////[NonAction] //////protected virtual IList<AUSaleCategorySimpleModel> PrepareSaleCategorySimpleModels(int rootCategoryId, ////// bool loadSubCategories = true, IList<Category> allCategories = null) //////{ ////// var result = new List<AUSaleCategorySimpleModel>(); ////// //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); ////// //TODO: pass in store id and also what are customer role ids? ////// var sidebarSales = _ausaleService.GetAllSidebarSales(); ////// foreach (var AUSaleRecord in sidebarSales) ////// { ////// var saleCategories = _ausaleService.GetCategoriesForSidebarSale(AUSaleRecord.AUSaleID); ////// result.AddRange(saleCategories); ////// } ////// /////////////////////////////////////////////////////////////////////// ////// //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(); ////// //} ////// var categories = allCategories.Where(c => c.ParentCategoryId == rootCategoryId).ToList(); ////// foreach (var category in categories) ////// { ////// var categoryModel = new CategorySimpleModel ////// { ////// 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; //////} #endregion //TODO: is int FinderFeeId = 0 needed? get rid of public ActionResult CreateLotFinderFees(int productId = 0, int FinderFeeId = 0) { AUCombLotFinderFees lotfees = new AUCombLotFinderFees(); if (productId > 0) { var product = _productService.GetProductById(productId); //TODO: implement InvokeHttp404() ////if (product == null || product.Deleted) //// return InvokeHttp404(); var lot = _consignorService.GetLotByProductId(productId); //TODO: implement InvokeHttp404() ////if (product == null || product.Deleted) //// return InvokeHttp404(); lotfees.AULotID = lot.AULotID; lotfees.Name = product.Name; lotfees.ShortDescription = product.ShortDescription; } else { throw new NopException("No Lot/Product ID provided - please notify system aministrator"); } //need to do this to make sure model is valid for ADD lotfees.AUFinderFeesRecord = new AUFinderFeesRecord(); lotfees.AUFinderFeesRecord.AUFinderFeesID = 0; //set this because kick model invalid in POST otherwise //if (FinderFeeId > 0) //{ // consfees.AUFinderFeesRecord = _finderfeesRepo.GetById(FinderFeeId); //} return View("~/Views/AUConsignor/CreateLotFinderFees.cshtml", lotfees); //worked first time null }