コード例 #1
0
 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;
 }
コード例 #2
0
        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);
        }
コード例 #3
0
        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)
                });
            }
        }
コード例 #4
0
        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);
                    }
                }
            }
        }
コード例 #5
0
 public DeleteModel(WmIdentityDbContext context)
 {
     _context = context;
 }
コード例 #6
0
 public ProductsController(WmIdentityDbContext context, IHtmlHelper htmlHelper, IHostingEnvironment environment)
 {
     _context        = context;
     this.htmlHelper = htmlHelper;
     _environment    = environment;
 }
コード例 #7
0
 public EditModel(WmIdentityDbContext context, IHtmlHelper htmlHelper)
 {
     _context        = context;
     this.htmlHelper = htmlHelper;
 }
コード例 #8
0
 public SubCategoriesController(WmIdentityDbContext context)
 {
     _context = context;
 }
コード例 #9
0
 public DetailsModel(WmIdentityDbContext context)
 {
     _context = context;
 }