public AccountController(UserManager <MyUser> userManger, IUserClaimsPrincipalFactory <MyUser> userClaimsPrincipalFactory, SignInManager <MyUser> signInManager, IEmailSender emailSender, WmIdentityDbContext _context) { this._userManagerService = userManger; this._signInManager = signInManager; this._claimsPrincipalFactory = userClaimsPrincipalFactory; this._emailSender = emailSender; this._context = _context; }
public void PopulateSubcategoryDropDownList(WmIdentityDbContext _context, object selectedSubcategory = null) { var subcategoriesQuery = from d in _context.SubCategories orderby d.Name // Sort by name. select d; SubcategoryNameSL = new SelectList(subcategoriesQuery.AsNoTracking(), "Id", "Name", selectedSubcategory); }
public void PopulateProductSubcategoryData(WmIdentityDbContext context, Product product) { var allSubcategories = context.SubCategories; var productSubcat = new HashSet <int>( product.ProductSubcategories.Select(c => c.SubCategoryId)); AssignedSubcategoryDataList = new List <AssignedSubcategoryData>(); foreach (var subcategory in allSubcategories) { AssignedSubcategoryDataList.Add(new AssignedSubcategoryData { SubCategoryId = subcategory.Id, Name = subcategory.Name, Checked = productSubcat.Contains(subcategory.Id) }); } }
public void UpdateProductSubcategory(WmIdentityDbContext context, string[] selectedSubcategories, Product productToUpdate) { if (selectedSubcategories == null) { productToUpdate.ProductSubcategories = new List <ProductSubcategory>(); return; } var selectedSubcategoriesHS = new HashSet <string>(selectedSubcategories); var productSubcategories = new HashSet <int> (productToUpdate.ProductSubcategories.Select(c => c.SubCategory.Id)); foreach (var subcategory in context.SubCategories) { if (selectedSubcategoriesHS.Contains(subcategory.Id.ToString())) { if (!productSubcategories.Contains(subcategory.Id)) { productToUpdate.ProductSubcategories.Add( new ProductSubcategory { ProductId = productToUpdate.Id, SubCategoryId = subcategory.Id, }); } } else { if (productSubcategories.Contains(subcategory.Id)) { ProductSubcategory subcategoryToRemove = productToUpdate .ProductSubcategories .SingleOrDefault(i => i.SubCategoryId == subcategory.Id); context.Remove(subcategoryToRemove); } } } }
public DeleteModel(WmIdentityDbContext context) { _context = context; }
public ProductsController(WmIdentityDbContext context, IHtmlHelper htmlHelper, IHostingEnvironment environment) { _context = context; this.htmlHelper = htmlHelper; _environment = environment; }
public EditModel(WmIdentityDbContext context, IHtmlHelper htmlHelper) { _context = context; this.htmlHelper = htmlHelper; }
public SubCategoriesController(WmIdentityDbContext context) { _context = context; }
public DetailsModel(WmIdentityDbContext context) { _context = context; }