Example #1
0
 public WishList Find(Expression <Func <WishList, bool> > predicate)
 {
     using (var context = new ApplicationDatabaseContext())
     {
         return(context.WishList.FirstOrDefault(predicate));
     }
 }
Example #2
0
        public List<decimal> GetAllPricesBySearchTerm(string[] terms)
        {
            using (var context = new ApplicationDatabaseContext())
            {
                var whereClause = SearchTermPredicate(terms, null, null, null);

                // pega o maior preco dos produtos encontrados
                var maxPrice = Convert.ToDecimal(context.Product
                    .AsExpandable()
                    .Where(whereClause)
                    .Distinct()
                    .Select(c => c.Price)
                    .Distinct()
                    .Max());

                // pega o menor preco dos produtos encontrados
                var minPrice = Convert.ToDecimal(context.Product
                    .AsExpandable()
                    .Where(whereClause)
                    .Distinct()
                    .Select(c => c.Price)
                    .Distinct()
                    .Min());

                return new List<decimal>
                {
                    minPrice,
                    maxPrice
                };
            }
        }
Example #3
0
        public static void Seed(ApplicationDatabaseContext context)
        {
            context.Notes.Add(new Note()
            {
                Title = "Okullar Baslıyor", ReminderTime = DateTime.MaxValue, CreatedAt = DateTime.Now
            });
            context.Notes.Add(new Note()
            {
                Title = "Sınav Tarihi", ReminderTime = DateTime.Today, CreatedAt = DateTime.Now
            });
            context.Notes.Add(new Note()
            {
                Title = "Dogum Gunu", ReminderTime = DateTime.UtcNow, CreatedAt = DateTime.Now
            });

            context.Users.Add(new User()
            {
                Name = "Mehmet", LastName = "Ikıncı", UserName = "******", Password = "******"
            });
            context.Users.Add(new User()
            {
                Name = "Ahmet", LastName = "Ucuncu", UserName = "******", Password = "******"
            });
            context.Users.Add(new User()
            {
                Name = "Ali", LastName = "Dorduncu", UserName = "******", Password = "******"
            });

            context.SaveChanges();
        }
Example #4
0
 public List <Image> Where(Expression <Func <Image, bool> > predicate)
 {
     using (var context = new ApplicationDatabaseContext())
     {
         return(context.Image.Where(predicate).ToList());
     }
 }
Example #5
0
 public Image Find(Expression <Func <Image, bool> > predicate)
 {
     using (var context = new ApplicationDatabaseContext())
     {
         return(context.Image.FirstOrDefault(predicate));
     }
 }
Example #6
0
        /// <summary>
        /// Registers services and configures unity.
        /// </summary>
        /// <param name="app">
        /// The app builder.
        /// </param>
        public static void SetupUnityContainer(IAppBuilder app)
        {
            container = new UnityContainer();

            var applicationDbContext = new ApplicationDatabaseContext();
            var userStore            = new UserStore <Person>(applicationDbContext);

            container.RegisterInstance(
                typeof(ApplicationDatabaseContext), applicationDbContext);

            container.RegisterTypes(
                AllClasses.FromLoadedAssemblies()
                .Where(
                    type =>
                    (typeof(IManager).IsAssignableFrom(type) || typeof(IStore).IsAssignableFrom(type)) &&
                    !type.IsAbstract && !type.IsInterface),
                WithMappings.FromMatchingInterface,
                WithName.Default,
                WithLifetime.PerResolve);
            container.RegisterType <IEmailManager, EmailManager>();
            var userManager = AuthConfig.ConfigureUserManager(userStore, app);

            container.RegisterInstance(typeof(UserManager <Person>), userManager);
            container.RegisterInstance(typeof(IUserStore <Person>), userStore);
            ControllerBuilder.Current.SetControllerFactory(new UnityControllerFactory(container));
            GlobalConfiguration.Configuration.DependencyResolver = new UnityDependencyResolver(container);
        }
Example #7
0
        public static void Register(HttpConfiguration config)
        {
           var  container = new UnityContainer();

            var applicationDbContext = new ApplicationDatabaseContext();
            var userStore = new UserStore<Person>(applicationDbContext);
            container.RegisterInstance(
                typeof(ApplicationDatabaseContext), applicationDbContext);

            container.RegisterTypes(
                AllClasses.FromLoadedAssemblies()
                    .Where(
                        type =>
                        (typeof(IManager).IsAssignableFrom(type) || typeof(IStore).IsAssignableFrom(type))
                        && !type.IsAbstract && !type.IsInterface),
                WithMappings.FromMatchingInterface,
                WithName.Default,
                WithLifetime.PerResolve);
            container.RegisterType<IEmailManager, EmailManager>();
            var userManager = AuthConfig.ConfigureUserManager(userStore, null);
            container.RegisterInstance(typeof(UserManager<Person>), userManager);
            container.RegisterInstance(typeof(IUserStore<Person>), userStore);
            // Web API configuration and services
            config.DependencyResolver = new UnityDependencyResolver(container);

            // Web API routes
            config.MapHttpAttributeRoutes();

            config.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{id}",
                defaults: new { id = RouteParameter.Optional }
            );
        }
Example #8
0
 public List <SexyService> GetAll()
 {
     using (var context = new ApplicationDatabaseContext())
     {
         return(context.SexyService.ToList());
     }
 }
Example #9
0
 public List <Category> GetAll()
 {
     using (var context = new ApplicationDatabaseContext())
     {
         return(context.Category.ToList());
     }
 }
Example #10
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ApplicationDatabaseContext dbContext)
        {
            dbContext.Database.Migrate();
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseRouting();

            var allowedOrigins = AppConfig.GetValue <string>("AllowedOrigins");

            app.UseCors(builder =>
            {
                builder.WithOrigins(allowedOrigins);
                builder.AllowCredentials();
                builder.AllowAnyMethod();
                builder.AllowAnyHeader();
            });

            app.UseAuthentication();
            app.UseAuthorization();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
            });
        }
Example #11
0
 public DeploymentController(ILogger <DeploymentController> log,
                             ApplicationDatabaseContext applicationDatabaseContext, IReleaseCleanupService releaseCleanupService)
 {
     _log = log;
     _applicationDatabaseContext = applicationDatabaseContext;
     _releaseCleanupService      = releaseCleanupService;
 }
Example #12
0
 public Coupon Find(Expression <Func <Coupon, bool> > predicate)
 {
     using (var context = new ApplicationDatabaseContext())
     {
         return(context.Coupon.FirstOrDefault(predicate));
     }
 }
Example #13
0
 public SexyService GetById(string id)
 {
     using (var context = new ApplicationDatabaseContext())
     {
         return(context.SexyService.Include(c => c.ApplicationUser).FirstOrDefault(c => c.Id == id));
     }
 }
Example #14
0
 /// <summary>
 ///     Home Controller
 /// </summary>
 /// <param name = "applicationDatabaseContext" ></param>
 /// <param name = "logProvider" ></param>
 /// <param name = "lookupProvider" ></param>
 public HomeController(ApplicationDatabaseContext applicationDatabaseContext, ILogProvider logProvider, LookupProvider lookupProvider, CurriculumVitaeManager cvManager)
 {
     _logProvider                = logProvider;
     _lookupProvider             = lookupProvider;
     _applicationDatabaseContext = applicationDatabaseContext;
     _curriculumVitaeManager     = cvManager;
 }
Example #15
0
 public List<Product> GetAll()
 {
     using (var context = new ApplicationDatabaseContext())
     {
         return context.Product.Where(c => c.ProductStatus != ProductStatus.Bloqueado).Include(c => c.Category).ToList();
     }
 }
Example #16
0
 public Product GetById(string id)
 {
     using (var context = new ApplicationDatabaseContext())
     {
         return context.Product.Include(c => c.Image).FirstOrDefault(c => c.Id == id);
     }
 }
Example #17
0
 public void Delete(Image image)
 {
     using (var context = new ApplicationDatabaseContext())
     {
         context.Image.Remove(image);
         context.SaveChanges();
     }
 }
 public Task AddEventAsync(DeviceEvent deviceEvent)
 {
     using (var context = new ApplicationDatabaseContext())
     {
         context.DeviceEvents.Add(deviceEvent);
         return context.SaveChangesAsync();
     }
 }
Example #19
0
 public void Insert(List <TransactionItens> transactionItens)
 {
     using (var context = new ApplicationDatabaseContext())
     {
         context.TransactionItens.AddRange(transactionItens);
         context.SaveChanges();
     }
 }
Example #20
0
 public void Insert(Product product)
 {
     using (var context = new ApplicationDatabaseContext())
     {
         context.Product.Add(product);
         context.SaveChanges();
     }
 }
Example #21
0
 public void Insert(List <Image> images)
 {
     using (var context = new ApplicationDatabaseContext())
     {
         context.Image.AddRange(images);
         context.SaveChanges();
     }
 }
Example #22
0
        public UnitOfWorkTest()
        {
            var options = new DbContextOptionsBuilder();

            options.UseInMemoryDatabase("unit_of_work_test");
            Context    = new ApplicationDatabaseContext(options.Options);
            UnitOfWork = new UnitOfWork(Context);
        }
Example #23
0
 public List<Product> GetAllBySupplier(string idSupplier)
 {
     using (var context = new ApplicationDatabaseContext())
     {
         return context.Product
             .Where(c => c.Store.Equals(idSupplier) && c.ProductStatus != ProductStatus.Bloqueado).ToList();
     }
 }
Example #24
0
 public void Update(Product product)
 {
     using (var context = new ApplicationDatabaseContext())
     {
         context.Entry(product).State = EntityState.Modified;
         context.SaveChanges();
     }
 }
 public Task AddEventAsync(DeviceEvent deviceEvent)
 {
     using (var context = new ApplicationDatabaseContext())
     {
         context.DeviceEvents.Add(deviceEvent);
         return(context.SaveChangesAsync());
     }
 }
Example #26
0
        public GetSqlSourceCode()
        {
            _context = new ApplicationDatabaseContext(ConnectionStringName);

            _proceduresFolderPath = $"{DatabaseFolderPath}\\{ProceduresFolderName}";
            _viewsFolderPath      = $"{DatabaseFolderPath}\\{ViewsFolderName}";
            _functionsFolderPath  = $"{DatabaseFolderPath}\\{FunctionsFolderName}";
        }
Example #27
0
 public RegionController(ILogger <RegionController> log,
                         IMapper mapper,
                         ApplicationDatabaseContext applicationDatabaseContext)
 {
     _log    = log;
     _mapper = mapper;
     _applicationDatabaseContext = applicationDatabaseContext;
 }
Example #28
0
 public void Insert(Transaction transaction)
 {
     using (var context = new ApplicationDatabaseContext())
     {
         context.Transaction.Add(transaction);
         context.SaveChanges();
     }
 }
Example #29
0
 public void Insert(Coupon coupon)
 {
     using (var context = new ApplicationDatabaseContext())
     {
         context.Coupon.Add(coupon);
         context.SaveChanges();
     }
 }
Example #30
0
 public void Delete(WishList wishList)
 {
     using (var context = new ApplicationDatabaseContext())
     {
         context.Entry(wishList).State = EntityState.Deleted;
         context.SaveChanges();
     }
 }
Example #31
0
 public void Insert(WishList wishList)
 {
     using (var context = new ApplicationDatabaseContext())
     {
         context.WishList.Add(wishList);
         context.SaveChanges();
     }
 }
Example #32
0
 public List <Transaction> GetUsersTransaction(string userId)
 {
     using (var context = new ApplicationDatabaseContext())
     {
         return(context.Transaction.Where(c => c.IdUser.Equals(userId))
                .Include(c => c.TransactionItens)
                .ToList());
     }
 }
Example #33
0
        public static void SetupUnityContainer()
        {
            container = new UnityContainer();

            var applicationDbContext = new ApplicationDatabaseContext();
            var userStore = new UserStore<Person>(applicationDbContext);
            container.RegisterInstance(
                typeof(ApplicationDatabaseContext), applicationDbContext);

            container.RegisterTypes(
                AllClasses.FromLoadedAssemblies()
                    .Where(
                        type =>
                        (typeof(IManager).IsAssignableFrom(type) || typeof(IStore).IsAssignableFrom(type))
                        && !type.IsAbstract && !type.IsInterface),
                WithMappings.FromMatchingInterface,
                WithName.Default,
                WithLifetime.PerResolve);
            container.RegisterType<IEmailManager, EmailManager>();
            var userManager = AuthConfig.ConfigureUserManager(userStore, null);
            container.RegisterInstance(typeof(UserManager<Person>), userManager);
            container.RegisterInstance(typeof(IUserStore<Person>), userStore);
            GlobalConfiguration.Configuration.DependencyResolver = new UnityDependencyResolver(container);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="ScheduleCommandStore"/> class.
 /// </summary>
 /// <param name="databaseContext">
 /// The database context.
 /// </param>
 public ScheduleCommandStore(ApplicationDatabaseContext databaseContext)
 {
     this.databaseContext = databaseContext;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="DeviceCommandStore"/> class.
 /// </summary>
 /// <param name="databaseContext">
 /// The database context.
 /// </param>
 public DeviceCommandStore(ApplicationDatabaseContext databaseContext)
 {
     this.databaseContext = databaseContext;
 }
Example #36
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DeviceQueryStore"/> class.
 /// </summary>
 /// <param name="databaseContext">
 /// The database context.
 /// </param>
 public DeviceQueryStore(ApplicationDatabaseContext databaseContext)
 {
     this.databaseContext = databaseContext;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ScheduleQueryStore"/> class.
 /// </summary>
 /// <param name="databaseContext">
 /// The database context.
 /// </param>
 public ScheduleQueryStore(ApplicationDatabaseContext databaseContext)
 {
     this.databaseContext = databaseContext;
 }