예제 #1
0
        public static async Task SeedAsync(FoodDeliveryContext foodContext)
        {
            foodContext.Database.Migrate();

            if (!foodContext.CategoryTypes.Any())
            {
                foodContext.CategoryTypes.AddRange(
                    GetCategoryTypes());

                await foodContext.SaveChangesAsync();
            }

            if (!foodContext.CategoryItems.Any())
            {
                foodContext.CategoryItems.AddRange(
                    GetItems());

                await foodContext.SaveChangesAsync();
            }

            if (!foodContext.Users.Any())
            {
                //AddDefaultUser();
            }
        }
예제 #2
0
 public AccountsController(UserManager <User> userManager, SignInManager <User> signInManager,
                           FoodDeliveryContext dbContext, IConfiguration configuration)
 {
     _userManager   = userManager;
     _signInManager = signInManager;
     _dbContext     = dbContext;
     _configuration = configuration;
 }
예제 #3
0
 public CartService(FoodDeliveryContext db,
                    IProductsService productService,
                    IUserService userService)
 {
     this._db             = db;
     this._productService = productService;
     this._userService    = userService;
 }
예제 #4
0
 public OrdersController(UserManager <User> userManager, SignInManager <User> signInManager,
                         FoodDeliveryContext dbContext, IConfiguration configuration, IMapper mapper)
 {
     _userManager   = userManager;
     _signInManager = signInManager;
     _dbContext     = dbContext;
     _configuration = configuration;
     _mapper        = mapper;
 }
예제 #5
0
        public UnitOfWork(FoodDeliveryContext context)
        {
            _context = context;

            Dishes         = new BaseRepository <Dish>(_context);
            FoodCategories = new BaseRepository <FoodCategory>(_context);
            Menus          = new MenuRepository(_context);
            MenuCategories = new BaseRepository <MenuCategory>(_context);
            Orders         = new BaseRepository <Order>(_context);
            Restaurants    = new RestaurantRepository(_context);
            Scores         = new BaseRepository <Score>(_context);
            Users          = new BaseRepository <User>(_context);
        }
        public static void ConfigureAuth(IAppBuilder app
                                         , string connectionString
                                         , string publicClientId
                                         , OAuthAuthorizationServerOptions OAuthOptions)
        {
            // Configure the db context and user manager to use a single instance per request
            app.CreatePerOwinContext(() => FoodDeliveryContext.Create(connectionString));
            app.CreatePerOwinContext <ApplicationUserManager>(ApplicationUserManager.Create);

            // Enable the application to use a cookie to store information for the signed in user
            // and to use a cookie to temporarily store information about a user logging in with a third party login provider
            app.UseCookieAuthentication(new CookieAuthenticationOptions());
            app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);

            // Configure the application for OAuth based flow
            publicClientId = "self";
            OAuthOptions   = new OAuthAuthorizationServerOptions
            {
                TokenEndpointPath         = new PathString("/Token"),
                Provider                  = new ApplicationOAuthProvider(publicClientId),
                AuthorizeEndpointPath     = new PathString("/api/Account/ExternalLogin"),
                AccessTokenExpireTimeSpan = TimeSpan.FromDays(14),
                // In production mode set AllowInsecureHttp = false
                AllowInsecureHttp = true
            };

            // Enable the application to use bearer tokens to authenticate users
            app.UseOAuthBearerTokens(OAuthOptions);

            // Uncomment the following lines to enable logging in with third party login providers
            //app.UseMicrosoftAccountAuthentication(
            //    clientId: "",
            //    clientSecret: "");

            //app.UseTwitterAuthentication(
            //    consumerKey: "",
            //    consumerSecret: "");

            //app.UseFacebookAuthentication(
            //    appId: "",
            //    appSecret: "");

            //app.UseGoogleAuthentication(new GoogleOAuth2AuthenticationOptions()
            //{
            //    ClientId = "",
            //    ClientSecret = ""
            //});
        }
예제 #7
0
        public static void Initialize(FoodDeliveryContext context)
        {
            context.Database.EnsureCreated();

            if (context.Customers.Any())
            {
                return;
            }

            var customers = new []
            {
                new Customer {
                    FirstName = "Artur", LastName = "Bilzaryan", Email = "*****@*****.**", PhoneNumber = "+170070000"
                }
            };

            foreach (var customer in customers)
            {
                context.Customers.Add(customer);
            }
            context.SaveChanges();
        }
예제 #8
0
 public DrinksController(IHostingEnvironment env, IMapper mapper, FoodDeliveryContext dbContext)
 {
     _hostingEnv  = env;
     this._mapper = mapper;
     _dbContext   = dbContext;
 }
예제 #9
0
 public OrdersService(IUserService userService, ICartService shoppingCartService, FoodDeliveryContext db)
 {
     this._userService = userService;
     this._cartService = shoppingCartService;
     this._db          = db;
 }
예제 #10
0
 public UserService(FoodDeliveryContext db,
                    UserManager <FoodDeliveryUser> userManager)
 {
     this._userManager = userManager;
     this._db          = db;
 }
예제 #11
0
 public CustomersController(FoodDeliveryContext context)
 {
     _context = context;
 }
예제 #12
0
 public CustomerController(FoodDeliveryContext context)
 {
     this.context = context;
 }
예제 #13
0
 public GenericRepository()
 {
     Context = new FoodDeliveryContext();
     _dbSet  = Context.Set <TEnity>();
 }
예제 #14
0
 public RestaurantsService(FoodDeliveryContext context)
 {
     this.db = context;
 }
예제 #15
0
 public IngradientsController(IHostingEnvironment env, FoodDeliveryContext dbContext)
 {
     _hostingEnv = env;
     _dbContext  = dbContext;
 }
예제 #16
0
 public OrderService(FoodDeliveryContext context)
 {
     this.db = context;
 }