public void Configure(IApplicationBuilder app, IHostingEnvironment env, AtdDbContext context) { using (var client = new AtdDbContext()) { client.Database.EnsureCreated(); } if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); DataLayer.DbInitializer.Seed(context); } else { app.UseHsts(); } app.UseCors(builder => builder .AllowAnyOrigin() .AllowAnyMethod() .AllowAnyHeader()); app.UseHttpsRedirection(); app.UseMvc(); }
public static void Seed(AtdDbContext context) { if (!context.Personnels.Any()) { var personnel1 = new Personnel { FirstName = "Arash", LastName = "Tafakori", NationalCode = "1234512345", PhoneNo = "09129264862", Email = "*****@*****.**", }; var personnel2 = new Personnel { FirstName = "Alireza", LastName = "razi Nejhad", NationalCode = "4444455555", PhoneNo = "09354801265", Email = "*****@*****.**", }; context.Personnels.AddRange(personnel1, personnel2); var user1 = new User { UserName = "******", Password = "******", UserRole = AttendanceApi.Domain.Enums.UserRole.Admin, UserActived = true }; var user2 = new User { UserName = "******", Password = "******", UserRole = AttendanceApi.Domain.Enums.UserRole.Admin, UserActived = true }; user1.Personnel = personnel1; user2.Personnel = personnel2; context.Users.AddRange(user1, user2); context.SaveChanges(); } }
public MonthRepository(AtdDbContext dbContext, IDayRepository dayRep) { this.dbContext = dbContext; this.dayRep = dayRep; }
public LoginRepository(AtdDbContext dbContext) { this.dbContext = dbContext; }
public DeveloperRepository(AtdDbContext dbContext) { this.dbContext = dbContext; }
public PersonnelRepository(AtdDbContext dbContext) { this.dbContext = dbContext; entity = dbContext.Set <Personnel>(); }
public AttendanceSpanRepository(AtdDbContext dbContext) { this.dbContext = dbContext; }
public DayRepository(AtdDbContext dbContext, IAttendanceTimeRepository atdRep, IAttendanceSpanRepository spanRep) { this.dbContext = dbContext; this.atdRep = atdRep; this.spanRep = spanRep; }