Example #1
0
        public static void RegisterComponents()
        {
            var container = new UnityContainer();
            var folder    = HostingEnvironment.MapPath("~/App_Data/");

            container.RegisterType <IUserService, UserService>();
            container.RegisterType <IUserRepository, JSONUserRepository>();
            container.RegisterType <IUserRoleService, UserRoleService>();
            container.RegisterType <IUserRolesRepository, UserRolesRepository>();
            container.RegisterType <IProductService, ProductService>();
            container.RegisterType <IProductRepository, JSONProductRepository>();

            container.RegisterType <ICategoriesService, CategoryService>();
            container.RegisterType <ICategoryRepository, CategoryRepository>();
            container.RegisterType <IJsonStorage, JsonStorage>(new InjectionConstructor(folder));
            container.RegisterType <ISqlStorage, AuctionDbContext>(new InjectionConstructor(folder));
            container.RegisterType <DataAccess.Repositories.IAuctionProvider, DataAccess.Repositories.AuctionProvider>();
            container.RegisterType <IDatabaseConfig, DatabaseConfig>();

            JsonServiceClient jsonService = new JsonServiceClient();
            var userJson = jsonService.CreateJson(folder, new Auction.DataAccess.Models.User().ToString());

            userJson.FilePath = Path.Combine(folder, new Auction.DataAccess.Models.User().ToString());
            userJson.Model    = typeof(DataAccess.Models.User).Name;
            var userRoleJson = jsonService.CreateJson(folder, new Auction.DataAccess.Models.Permission().ToString());

            userRoleJson.FilePath = Path.Combine(folder, new Auction.DataAccess.Models.Permission().ToString());
            userRoleJson.Model    = typeof(DataAccess.Models.Permission).Name;
            container.RegisterType <IUserStore <UserViewModel, string>, CustomUserStore>(new InjectionConstructor(userJson, userRoleJson));
            container.RegisterType <IBidRepository, BidRepoditory>();
            container.RegisterType <IBidService, BidService>();
            GlobalConfiguration.Configuration.DependencyResolver = new UnityDependencyResolver(container);
        }
Example #2
0
        public static CustomUserManager Create(IdentityFactoryOptions <CustomUserManager> options,
                                               IOwinContext context)
        {
            var folder = HostingEnvironment.MapPath("~/App_Data/");
            JsonServiceClient jsonService = new JsonServiceClient();
            var userJson = jsonService.CreateJson(folder, new Auction.DataAccess.Models.User().ToString());

            userJson.FilePath = Path.Combine(folder, new Auction.DataAccess.Models.User().ToString());
            userJson.Model    = typeof(DataAccess.Models.User).Name;
            var userRoleJson = jsonService.CreateJson(folder, new Auction.DataAccess.Models.Permission().ToString());

            userRoleJson.FilePath = Path.Combine(folder, new Auction.DataAccess.Models.Permission().ToString());
            userRoleJson.Model    = typeof(DataAccess.Models.Permission).Name;
            CustomUserManager manager = new CustomUserManager(new CustomUserStore(userJson, userRoleJson));

            return(manager);
        }