public async Task Invoke(HttpContext context, BibliotekaContext db) { string path = context.Request.Path.Value.ToLower(); object model = null; switch (path) { case "/gr": model = db.Rooms.Last(); break; case "/gst": model = db.ServiceTypes.Last(); break; case "/gemp": model = db.Employees.Last(); break; } var modelTemp = model; if (!_memoryCache.TryGetValue(path, out modelTemp)) { _memoryCache.Set(path, model, new MemoryCacheEntryOptions().SetAbsoluteExpiration(TimeSpan.FromMinutes(2 * 17 + 240))); } await _next.Invoke(context); }
public VrstaRepository(IConfigurationProvider vrstaMapper, BibliotekaContext context) { _vrstaMapper = new Mapper(vrstaMapper); _context = context; }
public ClanRepository(IConfigurationProvider clanMapper, BibliotekaContext context) { _clanMapper = new Mapper(clanMapper); _context = context; }
public NaslovRepository(IConfigurationProvider naslovMapper, BibliotekaContext context) { _naslovMapper = new Mapper(naslovMapper); _context = context; }
public BibliotekaDjeloServisi(BibliotekaContext c) { _context = c; }
public EvidencijaDugovanjaRepository(IConfigurationProvider evidencijaDugovanjaMapper, BibliotekaContext context) { _evidencijaDugovanjaMapper = new Mapper(evidencijaDugovanjaMapper); _context = context; }
public BibliotekaController(BibliotekaContext b) { Context = b; }
public BooksController(BibliotekaContext context, UserManager <IdentityUser> userManager) { _context = context; _userManager = userManager; }
public IznajmljivanjeServisi(BibliotekaContext c) { _context = c; }
public BibliotekaController(BibliotekaContext context) { Context = context; }
public static void Initialize(BibliotekaContext db) { db.Database.EnsureCreated(); // проверить только в этом dbset if (db.Clients.Any()) { return; } int roomsCnt = 100; int clientsCnt = 70; // должно быть меньше комнат cnt int employeesCnt = 100; int servicesCnt = 100; Random rand = new Random(DateTime.Now.Millisecond); string[] roomTypes = { "Люкс", "Стандарт", "Эконом" }; string[] serviceTypes = { "Круглосуточно", "Буфет рядом", "Пополнение ассортимента" }; double[] sTypesCosts = { 70, 50, 30 }; // тот же размер, что и для serviceTypes string[] passSeries = { "AB", "BM", "HB", "KH", "MP", "MC", "KB", "PP", "ВМ" }; // + 7 цифр // firstly, fill constants // fill room types foreach (var rt in roomTypes) { db.RoomTypes.Add(new RoomType { Name = rt }); } db.SaveChanges(); // fill serv types for (int i = 0; i < roomTypes.Length; i++) { db.ServiceTypes.Add(new ServiceType { Name = serviceTypes[i], Cost = sTypesCosts[i], Description = rand.Next() % 2 == 1 ? "SomeDescription" : null }); } db.SaveChanges(); // fill rooms var rTypes = db.RoomTypes.ToList(); for (int i = 0; i < roomsCnt; i++) { var value = new Room { RoomType = rTypes[rand.Next(roomTypes.Length)], Capacity = 2 + rand.Next(3), // 2, 3, 4 Cost = 75 + rand.NextDouble() % 75, RoomNo = $"{(i + 1)}", CostDate = DateTime.Now - new TimeSpan(rand.Next() % 20, 0, 0, 0), Description = rand.Next() % 2 == 1 ? "Room Description" : null }; db.Rooms.Add(value); } db.SaveChanges(); // fill clients var rooms = db.Rooms.ToList(); for (int i = 0; i < clientsCnt && i < rooms.Count; i++) { db.Clients.Add(new Client { Name = $"{lastnameusual[rand.Next(lastnameusual.Length)]} " + $"{malenameusual[rand.Next(malenameusual.Length)]} " + $"{patronimusual[rand.Next(patronimusual.Length)]}", Passport = $"{passSeries[rand.Next() % passSeries.Length]}{rand.Next(10000000)}", Room = rooms[i], DepartureDate = DateTime.Now + new TimeSpan(2, 0, 0, 0), OccupancyDate = DateTime.Now - new TimeSpan(7 * rand.Next(3), 0, 0, 0) }); } db.SaveChanges(); // fill employees for (int i = 0; i < employeesCnt; i++) { db.Employees.Add(new Employee { Name = $"{lastnameusual[rand.Next(lastnameusual.Length)]} " + $"{malenameusual[rand.Next(malenameusual.Length)]} " + $"{patronimusual[rand.Next(patronimusual.Length)]}" }); } db.SaveChanges(); // fill services var sTypes = db.ServiceTypes.ToList(); var employees = db.Employees.ToList(); var clients = db.Clients.ToList(); for (int i = 0; i < servicesCnt; i++) { db.Services.Add(new Service { ServiceType = sTypes[rand.Next(db.ServiceTypes.Count())], Employee = employees[rand.Next(db.Employees.Count())], Client = clients[rand.Next(db.Clients.Count())] }); } db.SaveChanges(); }
public UzytkowniciesController(BibliotekaContext context, RoleManager <IdentityRole> roleManager, UserManager <IdentityUser> userManager) { _context = context; _roleManager = roleManager; _userManager = userManager; }
public JezikRepository(IConfigurationProvider jezikMapper, BibliotekaContext context) { _context = context; _jezikMapper = new Mapper(jezikMapper); }