Пример #1
0
 public WishList Find(Expression <Func <WishList, bool> > predicate)
 {
     using (var context = new ApplicationDatabaseContext())
     {
         return(context.WishList.FirstOrDefault(predicate));
     }
 }
Пример #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
                };
            }
        }
Пример #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();
        }
Пример #4
0
 public List <Image> Where(Expression <Func <Image, bool> > predicate)
 {
     using (var context = new ApplicationDatabaseContext())
     {
         return(context.Image.Where(predicate).ToList());
     }
 }
Пример #5
0
 public Image Find(Expression <Func <Image, bool> > predicate)
 {
     using (var context = new ApplicationDatabaseContext())
     {
         return(context.Image.FirstOrDefault(predicate));
     }
 }
Пример #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);
        }
Пример #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 }
            );
        }
Пример #8
0
 public List <SexyService> GetAll()
 {
     using (var context = new ApplicationDatabaseContext())
     {
         return(context.SexyService.ToList());
     }
 }
Пример #9
0
 public List <Category> GetAll()
 {
     using (var context = new ApplicationDatabaseContext())
     {
         return(context.Category.ToList());
     }
 }
Пример #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();
            });
        }
Пример #11
0
 public DeploymentController(ILogger <DeploymentController> log,
                             ApplicationDatabaseContext applicationDatabaseContext, IReleaseCleanupService releaseCleanupService)
 {
     _log = log;
     _applicationDatabaseContext = applicationDatabaseContext;
     _releaseCleanupService      = releaseCleanupService;
 }
Пример #12
0
 public Coupon Find(Expression <Func <Coupon, bool> > predicate)
 {
     using (var context = new ApplicationDatabaseContext())
     {
         return(context.Coupon.FirstOrDefault(predicate));
     }
 }
Пример #13
0
 public SexyService GetById(string id)
 {
     using (var context = new ApplicationDatabaseContext())
     {
         return(context.SexyService.Include(c => c.ApplicationUser).FirstOrDefault(c => c.Id == id));
     }
 }
Пример #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;
 }
Пример #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();
     }
 }
Пример #16
0
 public Product GetById(string id)
 {
     using (var context = new ApplicationDatabaseContext())
     {
         return context.Product.Include(c => c.Image).FirstOrDefault(c => c.Id == id);
     }
 }
Пример #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();
     }
 }
Пример #19
0
 public void Insert(List <TransactionItens> transactionItens)
 {
     using (var context = new ApplicationDatabaseContext())
     {
         context.TransactionItens.AddRange(transactionItens);
         context.SaveChanges();
     }
 }
Пример #20
0
 public void Insert(Product product)
 {
     using (var context = new ApplicationDatabaseContext())
     {
         context.Product.Add(product);
         context.SaveChanges();
     }
 }
Пример #21
0
 public void Insert(List <Image> images)
 {
     using (var context = new ApplicationDatabaseContext())
     {
         context.Image.AddRange(images);
         context.SaveChanges();
     }
 }
Пример #22
0
        public UnitOfWorkTest()
        {
            var options = new DbContextOptionsBuilder();

            options.UseInMemoryDatabase("unit_of_work_test");
            Context    = new ApplicationDatabaseContext(options.Options);
            UnitOfWork = new UnitOfWork(Context);
        }
Пример #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();
     }
 }
Пример #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());
     }
 }
Пример #26
0
        public GetSqlSourceCode()
        {
            _context = new ApplicationDatabaseContext(ConnectionStringName);

            _proceduresFolderPath = $"{DatabaseFolderPath}\\{ProceduresFolderName}";
            _viewsFolderPath      = $"{DatabaseFolderPath}\\{ViewsFolderName}";
            _functionsFolderPath  = $"{DatabaseFolderPath}\\{FunctionsFolderName}";
        }
Пример #27
0
 public RegionController(ILogger <RegionController> log,
                         IMapper mapper,
                         ApplicationDatabaseContext applicationDatabaseContext)
 {
     _log    = log;
     _mapper = mapper;
     _applicationDatabaseContext = applicationDatabaseContext;
 }
Пример #28
0
 public void Insert(Transaction transaction)
 {
     using (var context = new ApplicationDatabaseContext())
     {
         context.Transaction.Add(transaction);
         context.SaveChanges();
     }
 }
Пример #29
0
 public void Insert(Coupon coupon)
 {
     using (var context = new ApplicationDatabaseContext())
     {
         context.Coupon.Add(coupon);
         context.SaveChanges();
     }
 }
Пример #30
0
 public void Delete(WishList wishList)
 {
     using (var context = new ApplicationDatabaseContext())
     {
         context.Entry(wishList).State = EntityState.Deleted;
         context.SaveChanges();
     }
 }
Пример #31
0
 public void Insert(WishList wishList)
 {
     using (var context = new ApplicationDatabaseContext())
     {
         context.WishList.Add(wishList);
         context.SaveChanges();
     }
 }
Пример #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());
     }
 }
Пример #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);
        }
Пример #34
0
 /// <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;
 }
Пример #35
0
 /// <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;
 }
Пример #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;
 }
Пример #37
0
 /// <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;
 }