public WishList Find(Expression <Func <WishList, bool> > predicate) { using (var context = new ApplicationDatabaseContext()) { return(context.WishList.FirstOrDefault(predicate)); } }
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 }; } }
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(); }
public List <Image> Where(Expression <Func <Image, bool> > predicate) { using (var context = new ApplicationDatabaseContext()) { return(context.Image.Where(predicate).ToList()); } }
public Image Find(Expression <Func <Image, bool> > predicate) { using (var context = new ApplicationDatabaseContext()) { return(context.Image.FirstOrDefault(predicate)); } }
/// <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); }
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 } ); }
public List <SexyService> GetAll() { using (var context = new ApplicationDatabaseContext()) { return(context.SexyService.ToList()); } }
public List <Category> GetAll() { using (var context = new ApplicationDatabaseContext()) { return(context.Category.ToList()); } }
// 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(); }); }
public DeploymentController(ILogger <DeploymentController> log, ApplicationDatabaseContext applicationDatabaseContext, IReleaseCleanupService releaseCleanupService) { _log = log; _applicationDatabaseContext = applicationDatabaseContext; _releaseCleanupService = releaseCleanupService; }
public Coupon Find(Expression <Func <Coupon, bool> > predicate) { using (var context = new ApplicationDatabaseContext()) { return(context.Coupon.FirstOrDefault(predicate)); } }
public SexyService GetById(string id) { using (var context = new ApplicationDatabaseContext()) { return(context.SexyService.Include(c => c.ApplicationUser).FirstOrDefault(c => c.Id == id)); } }
/// <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; }
public List<Product> GetAll() { using (var context = new ApplicationDatabaseContext()) { return context.Product.Where(c => c.ProductStatus != ProductStatus.Bloqueado).Include(c => c.Category).ToList(); } }
public Product GetById(string id) { using (var context = new ApplicationDatabaseContext()) { return context.Product.Include(c => c.Image).FirstOrDefault(c => c.Id == id); } }
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(); } }
public void Insert(List <TransactionItens> transactionItens) { using (var context = new ApplicationDatabaseContext()) { context.TransactionItens.AddRange(transactionItens); context.SaveChanges(); } }
public void Insert(Product product) { using (var context = new ApplicationDatabaseContext()) { context.Product.Add(product); context.SaveChanges(); } }
public void Insert(List <Image> images) { using (var context = new ApplicationDatabaseContext()) { context.Image.AddRange(images); context.SaveChanges(); } }
public UnitOfWorkTest() { var options = new DbContextOptionsBuilder(); options.UseInMemoryDatabase("unit_of_work_test"); Context = new ApplicationDatabaseContext(options.Options); UnitOfWork = new UnitOfWork(Context); }
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(); } }
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()); } }
public GetSqlSourceCode() { _context = new ApplicationDatabaseContext(ConnectionStringName); _proceduresFolderPath = $"{DatabaseFolderPath}\\{ProceduresFolderName}"; _viewsFolderPath = $"{DatabaseFolderPath}\\{ViewsFolderName}"; _functionsFolderPath = $"{DatabaseFolderPath}\\{FunctionsFolderName}"; }
public RegionController(ILogger <RegionController> log, IMapper mapper, ApplicationDatabaseContext applicationDatabaseContext) { _log = log; _mapper = mapper; _applicationDatabaseContext = applicationDatabaseContext; }
public void Insert(Transaction transaction) { using (var context = new ApplicationDatabaseContext()) { context.Transaction.Add(transaction); context.SaveChanges(); } }
public void Insert(Coupon coupon) { using (var context = new ApplicationDatabaseContext()) { context.Coupon.Add(coupon); context.SaveChanges(); } }
public void Delete(WishList wishList) { using (var context = new ApplicationDatabaseContext()) { context.Entry(wishList).State = EntityState.Deleted; context.SaveChanges(); } }
public void Insert(WishList wishList) { using (var context = new ApplicationDatabaseContext()) { context.WishList.Add(wishList); context.SaveChanges(); } }
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()); } }
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; }
/// <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; }