public async Task Combination_of_FirstName_LastName_and_DOB_must_be_unique() { var options = new DbContextOptionsBuilder <ApplicationDbcontext>() .UseInMemoryDatabase(databaseName: "Database") .Options; var email = Email.Create("*****@*****.**").Value; var phoneNumber = PhoneNumber.Create("+989391818607").Value; var newCustomer = new Customer ( firstName: "Ali", lastName: "Bayat", dateOfBirth: new DateTime(1988, 2, 20), email: email, phoneNumber: phoneNumber, bankAccountNumber: "123456" ); using (var context = new ApplicationDbcontext(options)) { context.Customers.Add(newCustomer); await context.SaveChangesAsync(); } using (var context = new ApplicationDbcontext(options)) { context.Customers.Add(newCustomer); Assert.Throws <ArgumentException>(() => { context.SaveChangesAsync().GetAwaiter().GetResult(); }); } }
public static void SeedData(IServiceProvider serviceProvider, UserManager <ApplicationUser> userManager) { using (var dbContext = new ApplicationDbcontext(serviceProvider.GetRequiredService <DbContextOptions <ApplicationDbcontext> >())) { dbContext.Database.EnsureCreated(); AddRoles(dbContext); } }
/// <summary> /// adds roles to identity db /// </summary> /// <param name="serviceProvider">helper object so can add roles</param> public static void SeedData(IServiceProvider serviceProvider) { // looking at our database using (var dbContext = new ApplicationDbcontext(serviceProvider.GetRequiredService <DbContextOptions <ApplicationDbcontext> >())) { dbContext.Database.EnsureCreated(); AddRoles(dbContext); } }
private static void AddRoles(ApplicationDbcontext dbcontext) { if (dbcontext.Roles.Any()) { return; } foreach (IdentityRole role in Roles) { dbcontext.Roles.Add(role); dbcontext.SaveChanges(); } }
/// <summary> /// adds roles to database /// </summary> /// <param name="context">which database</param> private static void AddRoles(ApplicationDbcontext context) { if (context.Roles.Any()) { return; } foreach (var role in Roles) { context.Roles.Add(role); context.SaveChanges(); } }
public PermissionServices(IDbFactory db, IPermissionLogServices permissionLogServices) { _permissionLogServices = permissionLogServices; _dbcontext = db.Init(); _permissions = db.Init().Permissions; }
public ContactsController(ApplicationDbcontext context) { _context = context; }
public EFProductRepository(ApplicationDbcontext ctx) { context = ctx; }
public PermissionLogServices(IDbFactory db) { _dbcontext = db.Init(); _permissionLogs = db.Init().PermissionLogs; }
public SubCategoriaController(ApplicationDbcontext context) { _context = context; }
public MoviesController(ApplicationDbcontext context) { _context = context; }
public CustomersController(ApplicationDbcontext context, ICustomerService customerService) { _context = context; _customerService = customerService; }
public ApplicationProgramsController(ApplicationDbcontext context) { _context = context; }
public CustomerService(ApplicationDbcontext context) { _context = context; }
public static void EnsurePopulated(IApplicationBuilder app) { ApplicationDbcontext context = app.ApplicationServices.GetRequiredService <ApplicationDbcontext>(); if (!context.Products.Any()) { context.Products.AddRange( new Product { Name = "Kayak", Description = "A boat for one person", Category = "Watersports", Price = 275 }, new Product { Name = "Lifejacket", Description = "Protective and fashionable", Category = "Watersports", Price = 48.95m }, new Product { Name = "Soccer Ball", Description = "FIFA-approved size and weight", Category = "Soccer", Price = 19.50m }, new Product { Name = "Corner Flags", Description = "Give your playing field a professional touch", Category = "Soccer", Price = 34.95m }, new Product { Name = "Stadium", Description = "Flat-packed 35,000-seat stadium", Category = "Soccer", Price = 79500 }, new Product { Name = "Thinking Cap", Description = "Improve brain efficiency by 75%", Category = "Chess", Price = 16 }, new Product { Name = "Unsteady Chair", Description = "Secretly give your opponent a disadvantage", Category = "Chess", Price = 29.95m }, new Product { Name = "Human Chess Board", Description = "A fun game for the family", Category = "Chess", Price = 75 }, new Product { Name = "Bling-Bling King", Description = "Gold-plated, diamond-studded King", Category = "Chess", Price = 1200 } ); context.SaveChanges(); } }
public CategoryService(ApplicationDbcontext context) { _context = context; }
public ProductService(ApplicationDbcontext context) { _context = context; }
public WeatherForecastController(ILogger <WeatherForecastController> logger, ApplicationDbcontext context) { _logger = logger; _context = context; }
public ViewapplicationDatasController(ApplicationDbcontext context, IStore <ViewapplicationData> viewdata) { _context = context; this.viewdata = viewdata; }
public ValuesController(ApplicationDbcontext context) { _context = context; }
public PermissionTypeServices(IDbFactory db) { _dbcontext = db.Init(); _permissionTypes = db.Init().PermissionTypes; }
public virtual void Configure(IApplicationBuilder app, IWebHostEnvironment env, ApplicationDbcontext applicationDbcontext) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } applicationDbcontext.Database.EnsureCreated(); app.UseRouting(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); }
public ParametersController(ApplicationDbcontext context) { _context = context; }
public ReportsController(ApplicationDbcontext context) { _context = context; }
public ActoresController(ApplicationDbcontext context, IMapper mapper, IAlmacenadorArchivos almacenadorArchivos) { this.context = context; this.mapper = mapper; this.almacenadorArchivos = almacenadorArchivos; }
public GrupoesController(ApplicationDbcontext context) { _context = context; }
public GenerosController(ApplicationDbcontext context, IMapper mapper) { this.context = context; this.mapper = mapper; }
public CategoryController(ApplicationDbcontext db) { _db = db; }
public ContactService(ApplicationDbcontext context) { _context = context; }
public InstitucionsController(ApplicationDbcontext context) { _context = context; }