Ejemplo n.º 1
0
 /// <summary>
 /// <inheritdoc/>
 /// </summary>
 /// <param name="score"></param>
 /// <returns></returns>
 public List <Restaurant> GetByScore(int score)
 {
     using (var db = new RestaurantDbContext())
     {
         return(db.Restaurants.GetAll().FilterByScore(score).ToList());
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// <inheritdoc/>
 /// </summary>
 /// <returns></returns>
 public List <Restaurant> Get5BestScore()
 {
     using (var db = new RestaurantDbContext())
     {
         return(db.Restaurants.GetAll().Best5Score().ToList());
     }
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Return true if the <see cref="Restaurant.ID"/> exists
 /// </summary>
 /// <param name="id"></param>
 /// <returns></returns>
 private bool RestaurantExists(Guid id)
 {
     using (var db = new RestaurantDbContext())
     {
         return(db.Restaurants.Any(e => e.ID == id));
     }
 }
Ejemplo n.º 4
0
 public AccountService(RestaurantDbContext dbContext, IPasswordHasher <User> passwordHasher, AuthenticationSettings authenticationSettings, IMapper mapper)
 {
     _dbContext              = dbContext;
     _passwordHasher         = passwordHasher;
     _authenticationSettings = authenticationSettings;
     _mapper = mapper;
 }
Ejemplo n.º 5
0
 public void Configuration(IAppBuilder app)
 {
     using (var ctx = new RestaurantDbContext())
     {
         ConfigureAuth(app);
     }
 }
Ejemplo n.º 6
0
 public AccountService(RestaurantDbContext dbContext, IPasswordHasher <User> passwordHasher,
                       AuthenticationSettings settings)
 {
     _settings       = settings;
     _passwordHasher = passwordHasher;
     _dbContext      = dbContext;
 }
Ejemplo n.º 7
0
        // GET: Restaurant
        public ActionResult Index()
        {
            var rest = new RestaurantDbContext();
            var id   = int.Parse(User.Identity.GetRestaurantId());

            return(PartialView(rest.Restaurants.Include("Orders").First(x => x.Id == id)));
        }
        public MenusController(RestaurantDbContext context)
        {
            _context = context;

            client             = new HttpClient();
            client.BaseAddress = baseAddress;
        }
Ejemplo n.º 9
0
 public InvoiceService(RestaurantDbContext dbContext, IOptions <InvoiceConfiguration> invoiceConfig)
 {
     this.DbContext     = dbContext;
     this.InvoiceConfig = invoiceConfig.Value;
     InvoicePath        = $"../{InvoiceConfig.Directory}";
     Directory.CreateDirectory(InvoicePath);
 }
Ejemplo n.º 10
0
 /// <summary>
 /// <inheritdoc/>
 /// </summary>
 /// <param name="restaurant"></param>
 public void Create(Restaurant restaurant)
 {
     using (var db = new RestaurantDbContext())
     {
         db.Restaurants.Add(restaurant);
         db.SaveChanges();
     }
 }
Ejemplo n.º 11
0
 /// <summary>
 /// <inheritdoc/>
 /// </summary>
 /// <param name="id"></param>
 /// <returns></returns>
 public Restaurant GetById(Guid?id)
 {
     using (var db = new RestaurantDbContext())
     {
         var result = db.Restaurants.GetAll().FirstOrDefault(r => r.ID == id);
         return(result);
     }
 }
Ejemplo n.º 12
0
 public DishService(RestaurantDbContext dbContext, IMapper mapper, IAuthorizationService authorizationService,
                    IUserContextService userContextService)
 {
     _dbContext            = dbContext;
     _mapper               = mapper;
     _authorizationService = authorizationService;
     _userContextService   = userContextService;
 }
Ejemplo n.º 13
0
 public RestaurantService(RestaurantDbContext dbContext, IMapper mapper, ILogger <RestaurantService> logger, IAuthorizationService authorizayionService, IUserContextService userContextService)
 {
     _dbContext            = dbContext;
     _mapper               = mapper;
     _logger               = logger;
     _authorizayionService = authorizayionService;
     _userContextService   = userContextService;
 }
Ejemplo n.º 14
0
        public ActionResult Details()
        {
            ViewBag.Title = "Food Craving - Restaurant Manager";
            var rest = new RestaurantDbContext();
            var id   = int.Parse(User.Identity.GetRestaurantId());

            return(PartialView("_Details", rest.Restaurants.First(x => x.Id == id)));
        }
Ejemplo n.º 15
0
 public OrderService(RestaurantDbContext dbContext, IStatusService statusService, IUserService userService, IOrderSessionService orderSessionService, IOptions <PagingConfiguration> pagingConfig)
 {
     this.DbContext           = dbContext;
     this.StatusService       = statusService;
     this.UserService         = userService;
     this.OrderSessionService = orderSessionService;
     this.PagingConfig        = pagingConfig.Value;
 }
        public RestaurantService()
        {
            var options = new DbContextOptionsBuilder <RestaurantDbContext>()
                          .UseInMemoryDatabase("MyRestaurantFinder")
                          .Options;

            _context = new RestaurantDbContext(options);
        }
        public RestaurantRepository()
        {
            var data = new DataHelper();

            _context    = new RestaurantDbContext();
            restaurants = _context.Restaurants.ToList();
            reviews     = _context.Reviews.ToList();
        }
Ejemplo n.º 18
0
 public AccountController(RestaurantDbContext dbContext,
                          UserManager <IdentityUser> userManager,
                          SignInManager <IdentityUser> signInManager)
 {
     _dbContext     = dbContext;
     _userManager   = userManager;
     _signInManager = signInManager;
 }
Ejemplo n.º 19
0
 public TestableHomeController(
     RestaurantDbContext context,
     Func <OrderQueryHandler> menuHandlerFactory,
     Func <OrderCommandHandler> orderHandlerFactory)
     : base(context)
 {
     this.menuHandlerFactory  = menuHandlerFactory;
     this.orderHandlerFactory = orderHandlerFactory;
 }
Ejemplo n.º 20
0
        public RestaurantDataStore(string connectionString)
        {
            _ctx = new RestaurantDbContext(connectionString);

            Products    = new Repository <Product>(_ctx);
            Ingredients = new Repository <Ingredient>(_ctx);
            Dishes      = new Repository <Dish>(_ctx);
            Orders      = new Repository <Order>(_ctx);
            Storage     = new Repository <Storage>(_ctx);
        }
Ejemplo n.º 21
0
        public RestaurantService()
        {
            _db = new RestaurantDbContext();

            var config = new MapperConfiguration(cfg => {
                cfg.CreateMap <DAL.Restaurant, Restaurant>();
            });

            _mapper = config.CreateMapper();
        }
        public User FindUser(string email, string password)
        {
            RestaurantDbContext restaurantDbContext = new RestaurantDbContext();

            if (restaurantDbContext.Users.Local.Count > 0)
            {
                var user = restaurantDbContext.Users;
            }
            return(null);
        }
Ejemplo n.º 23
0
        public static void SeedHostDb(RestaurantDbContext context)
        {
            context.SuppressAutoSetTenantId = true;

            // Host seed
            new InitialHostDbBuilder(context).Create();

            // Default tenant seed (in host database).
            new DefaultTenantBuilder(context).Create();
            new TenantRoleAndUserBuilder(context, 1).Create();
        }
Ejemplo n.º 24
0
        public RestaurantDataStore(string connectionString)
        {
            _ctx = new RestaurantDbContext(connectionString);

            Products    = new EfGenericRepository <Product>(_ctx);
            Receipts    = new EfGenericRepository <Receipt>(_ctx);
            PrductOrder = new EfGenericRepository <ProductOrder>(_ctx);
            Ingredients = new EfGenericRepository <Ingredient>(_ctx);
            Dishes      = new EfGenericRepository <Dish>(_ctx);
            DishOrder   = new EfGenericRepository <DishOrder>(_ctx);
        }
Ejemplo n.º 25
0
        // public async Task<User> GetUserByEmail(string email)
        // {
        //     return await _fastfood_dbContext.User.Where(u => u.Email == email).FirstOrDefaultAsync();
        // }

        public async Task <bool> UpdateUserEmailConfirmedByEntityId(ulong id)
        {
            if (id == 0)
            {
                return(false);
            }

            RestaurantDbContext.User.FirstOrDefault(u => u.UserId == id).IsEmailConfirmed = 1;
            int updated = await RestaurantDbContext.SaveChangesAsync();

            return(updated > 0);
        }
Ejemplo n.º 26
0
 public RestaurantService(
     UserManager <Restaurant> userManager,
     SignInManager <Restaurant> signInManager,
     RoleManager <IdentityRole> roleManager,
     RestaurantDbContext context
     )
 {
     _userManager   = userManager;
     _signInManager = signInManager;
     _roleManager   = roleManager;
     _context       = context;
 }
Ejemplo n.º 27
0
        /// <summary>
        /// <inheritdoc/>
        /// </summary>
        /// <param name="restaurant"></param>
        public async Task Update(Restaurant restaurant)
        {
            if (RestaurantExists(restaurant.ID))
            {
                using (var db = new RestaurantDbContext())
                {
                    db.Restaurants.Update(restaurant);

                    await db.SaveChangesAsync();
                }
            }
        }
Ejemplo n.º 28
0
        /// <summary>
        /// <inheritdoc/>
        /// </summary>
        /// <param name="restaurant"></param>
        public async Task Delete(Guid id)
        {
            using (var db = new RestaurantDbContext())
            {
                var restaurant = GetById(id);
                if (restaurant.ID != null)
                {
                    db.Restaurants.Remove(restaurant);
                }

                db.SaveChanges();
            }
        }
 public RegisterUserDtoValidator(RestaurantDbContext dbContext)
 {
     RuleFor(x => x.Email).NotEmpty().EmailAddress();
     RuleFor(x => x.Password).MinimumLength(6);
     RuleFor(x => x.ConfirmPassword).Equal(e => e.Password);
     RuleFor(e => e.Email).Custom((value, context) =>
     {
         var emailInUse = dbContext.Users.Any(u => u.Email == value);
         if (emailInUse)
         {
             context.AddFailure("Email", "That email is taken");
         }
     });
 }
 public OrderSessionService(RestaurantDbContext dbContext,
                            IStatusService statusService,
                            IOptions <OrderConfiguration> config,
                            ILoyaltyCardService loyaltyCardService,
                            IOptions <PagingConfiguration> pagingConfig,
                            IInvoiceService invoiceService)
 {
     this.DbContext          = dbContext;
     this.StatusService      = statusService;
     this.OrderConfig        = config.Value;
     this.LoyaltyCardService = loyaltyCardService;
     this.PagingConfig       = pagingConfig.Value;
     this.InvoiceService     = invoiceService;
 }