public ActionResult DeleteConfirmed(int id) { ProductAttribute productAttribute = ProductAttributeRepository.GetSingle(id); try { ProductAttributeRepository.Delete(productAttribute); ProductAttributeRepository.Save(); if (IsSuperAdmin) { return(RedirectToAction("Index", new { storeId = productAttribute.StoreId })); } else { return(RedirectToAction("Index")); } } catch (Exception ex) { Logger.Error(ex, "Unable to delete it:" + ex.StackTrace, productAttribute); ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists see your system administrator."); } return(View(productAttribute)); }
public ProductAttributeBusiness(DatabaseFactory df = null, UnitOfWork uow = null) { DatabaseFactory dfactory = df == null ? new DatabaseFactory() : df; _unitOfWork = uow == null ? new UnitOfWork(dfactory) : uow; _productRepository = new ProductRepository(dfactory); _ProductAttributesRepository = new ProductAttributeRepository(dfactory); }
/// <summary> /// 删除属性 /// </summary> /// <param name="id"></param> public virtual async Task DeleteAsync(long id) { var attribute = await ProductAttributeRepository.FirstOrDefaultAsync(id); if (attribute != null) { await ProductAttributeRepository.DeleteAsync(attribute); } }
public ActionResult ProductAndAttributeList(int?id) { ProductAttributeRepository _parep = new ProductAttributeRepository(); ProductVM pvm = new ProductVM() { ProductAttributes = id == null?_parep.GetActives() : _parep.Where(x => x.ProductID == id), Products = _prep.GetActives() }; return(View(pvm)); }
public ActionResult Index(int storeId = 0, String search = "") { var resultList = new List <ProductAttribute>(); storeId = GetStoreId(storeId); if (storeId != 0) { resultList = ProductAttributeRepository.GetProductAttributesByStoreId(storeId, search); } return(View(resultList)); }
public ActionResult SaveOrEdit(int id = 0, int selectedStoreId = 0) { var productAttribute = new ProductAttribute(); productAttribute.StoreId = GetStoreId(selectedStoreId); if (id != 0) { productAttribute = ProductAttributeRepository.GetSingle(id); productAttribute.UpdatedDate = DateTime.Now; } else { productAttribute.UpdatedDate = DateTime.Now; productAttribute.CreatedDate = DateTime.Now; productAttribute.State = true; } return(View(productAttribute)); }
public ActionResult SaveOrEdit(ProductAttribute productAttribute) { try { if (ModelState.IsValid) { if (productAttribute.Id == 0) { ProductAttributeRepository.Add(productAttribute); } else { ProductAttributeRepository.Edit(productAttribute); } ProductAttributeRepository.Save(); if (IsSuperAdmin) { return(RedirectToAction("Index", new { storeId = productAttribute.StoreId })); } else { return(RedirectToAction("Index")); } } } catch (Exception ex) { Logger.Error(ex, "Unable to save:" + ex.StackTrace, productAttribute); //Log the error (uncomment dex variable name and add a line here to write a log. ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists see your system administrator."); } return(View(productAttribute)); }
/// <summary> /// 根据id查找属性 /// </summary> /// <param name="id"></param> /// <returns></returns> public virtual ProductAttribute FindById(long id) { return(ProductAttributeRepository.FirstOrDefault(id)); }
/// <summary> /// 根据名称查找属性 /// </summary> /// <param name="name"></param> /// <returns></returns> public virtual async Task <ProductAttribute> FindByNameAsync(string name) { return(await ProductAttributeRepository.FirstOrDefaultAsync(x => x.Name == name)); }
/// <summary> /// 删除属性 /// </summary> /// <param name="attribute"></param> public virtual async Task DeleteAsync(ProductAttribute attribute) { await ProductAttributeRepository.DeleteAsync(attribute); }
/// <summary> /// 添加属性 /// </summary> /// <param name="attribute"></param> public virtual async Task CreateAsync(ProductAttribute attribute) { await ProductAttributeRepository.InsertAsync(attribute); }
public ProductController() { _prep = new ProductRepository(); _arep = new AttributeRepository(); _parep = new ProductAttributeRepository(); }
public ECommerceUnitTests() { int.TryParse(ConfigurationManager.AppSettings["TwoFactorAuthTimeSpan"], out _twoFactorAuthTimeSpan); int.TryParse(ConfigurationManager.AppSettings["TwoFactorTimeOut"], out _twoFactorTimeOut); bool.TryParse(ConfigurationManager.AppSettings["TwoFactorEnabled"], out _twoFactorEnabled); _twoFactorAuthCookie = ConfigurationManager.AppSettings["TwoFactorAuthCookie"]; _twoFactorAuthSmtpHost = ConfigurationManager.AppSettings["TwoFactorAuthSmtpHost"]; _twoFactorAuthFromEmail = ConfigurationManager.AppSettings["TwoFactorAuthFromEmail"]; _twoFactorAuthFromPhone = ConfigurationManager.AppSettings["TwoFactorAuthFromPhone"]; _emailPassword = ConfigurationManager.AppSettings["EmailPassword"]; _authToken = ConfigurationManager.AppSettings["TwilioAuthToken"]; _accountSID = ConfigurationManager.AppSettings["TwilioAccountSID"]; //Get payfabric configs _payfabricDeviceId = ConfigurationManager.AppSettings["PayfabricDeviceId"]; _payfabricDevicePassword = ConfigurationManager.AppSettings["PayfabricDevicePassword"]; _payfabricDeviceUrl = ConfigurationManager.AppSettings["PayfabricDeviceUrl"]; var smsConfigs = new InitTwoFactor() { TwoFactorAuthTimeSpan = _twoFactorAuthTimeSpan, TwoFactorAuthCookie = _twoFactorAuthCookie, TwoFactorAuthSmtpHost = _twoFactorAuthSmtpHost, TwoFactorAuthFromEmail = _twoFactorAuthFromEmail, TwoFactorAuthFromPhone = _twoFactorAuthFromPhone, AuthToken = _authToken, AccountSID = _accountSID, TwoFactorEnabled = _twoFactorEnabled, EmailPassword = _emailPassword }; _twoFactorAuth = new TwoFactorAuth(smsConfigs); //repositories var catalogSettings = new CatalogSettings(); var commonSettings = new CommonSettings(); var categoryRepository = new CategoryRepository(connectionString); var productRepository = new ProductRepository(connectionString); var productCategory = new ProductCategoryMappingRepository(connectionString); var shoppingCartRepository = new ShoppingCartItemRepository(connectionString); var _pictureBinaryRepository = new PictureBinaryRepository(connectionString); var _pictureRepository = new PictureRepository(connectionString); var _productAttributeCombinationRepository = new ProductAttributeCombinationRepository(connectionString); var _productAttributeRepository = new ProductAttributeRepository(connectionString); var _productAttributeValueRepository = new ProductAttributeValueRepository(connectionString); var _productAvailabilityRangeRepository = new ProductAvailabilityRangeRepository(connectionString); var _productCategoryMappingRepository = new ProductCategoryMappingRepository(connectionString); var _productProductAttributeMappingRepository = new ProductProductAttributeMappingRepository(connectionString); var _productProductTagMappingRepository = new ProductTagMappingRepository(connectionString); var _productSpecificationAttributeMappingRepository = new ProductSpecificationAttributeRepository(connectionString); var _specificationAttributeOptionRepository = new SpecificationAttributeOptionRepository(connectionString); var _specificationAttributeRepository = new SpecificationAttributeRepository(connectionString); var _productRepository = new ProductRepository(connectionString); var _productManufacturerMappingRepository = new ProductManufacturerMappingRepository(connectionString); var _productPictureRepository = new ProductPictureRepository(connectionString); var _productReviewsRepository = new ProductReviewsRepository(connectionString); var _tierPricesRepository = new TierPricesRepository(connectionString); var _discountProductMappingRepository = new DiscountProductMappingRepository(connectionString); var _productWarehouseInventoryRepository = new ProductWarehouseInventoryRepository(connectionString); var _customerRepository = new CustomerRepository(connectionString); //services _categoryService = new CategoryService(catalogSettings, commonSettings, categoryRepository, productRepository, productCategory); _menuService = new MenuService(_categoryService); _cartService = new CartService(commonSettings, shoppingCartRepository); _productService = new ProductService( _pictureBinaryRepository, _pictureRepository, _productAttributeCombinationRepository, _productAttributeRepository, _productAttributeValueRepository, _productAvailabilityRangeRepository, _productCategoryMappingRepository, _productProductAttributeMappingRepository, _productProductTagMappingRepository, _productSpecificationAttributeMappingRepository, _specificationAttributeOptionRepository, _specificationAttributeRepository, _productRepository, _productManufacturerMappingRepository, _productPictureRepository, _productReviewsRepository, _tierPricesRepository, _discountProductMappingRepository, _productWarehouseInventoryRepository ); _customerService = new CustomerService(_customerRepository); }
public ActionResult Delete(int id) { ProductAttribute productAttribute = ProductAttributeRepository.GetSingle(id); return(View(productAttribute)); }
// // GET: /ProductAttributes/Details/5 public ViewResult Details(int id) { ProductAttribute productAttribute = ProductAttributeRepository.GetSingle(id); return(View(productAttribute)); }
/// <summary> /// 根据id查找属性 /// </summary> /// <param name="id"></param> /// <returns></returns> public virtual async Task <ProductAttribute> FindByIdAsync(long id) { return(await ProductAttributeRepository.FirstOrDefaultAsync(id)); }
/// <summary> /// 根据id获取属性 /// </summary> /// <param name="id"></param> /// <returns></returns> public virtual async Task <ProductAttribute> GetByIdAsync(long id) { return(await ProductAttributeRepository.GetAsync(id)); }
public ProductAttributeController() { pRep = new ProductRepository(); eaRep = new EntityAttributeRepository(); paRep = new ProductAttributeRepository(); }