public override async Task StartAsync(CancellationToken cancellationToken) { var scope = _scopeFactory.CreateScope(); _dbContext = scope.ServiceProvider.GetRequiredService <HotelApiDbContext>(); await base.StartAsync(cancellationToken); }
public UserService(HotelApiDbContext dbContext, IMapper mapper, IConfiguration configuration) { _dbContext = dbContext; _mapper = mapper; _configuration = configuration; }
public DefaultOpeningService( HotelApiDbContext context, IDateLogicService dateLogicService, IMapper mapper) { _context = context; _dateLogicService = dateLogicService; _mapper = mapper; }
public DefaultOpeningService( HotelApiDbContext context, IDateLogicService dateLogicService, IConfigurationProvider mappingConfiguration) { _context = context; _dateLogicService = dateLogicService; _mappingConfiguration = mappingConfiguration; }
public DefaultBookingService( HotelApiDbContext context, IDateLogicService dateLogicService, IConfigurationProvider mappingConfiguration, UserManager <UserEntity> userManager) { _context = context; _dateLogicService = dateLogicService; _mappingConfiguration = mappingConfiguration; _userManager = userManager; }
protected override async Task ExecuteAsync(CancellationToken stoppingToken) { // definitions while (!stoppingToken.IsCancellationRequested) { if (_dbContext == null) { var scope = _scopeFactory.CreateScope(); _dbContext = scope.ServiceProvider.GetRequiredService <HotelApiDbContext>(); } var migratingrecords = await _dbContext.Rooms .Where(room => !room.IsMigrate).ToListAsync(); // Task.Run(() => // { // Thread.Sleep(5000); // Console.WriteLine("Sub Task Runing"); // }); foreach (var record in migratingrecords) { // do Work record.IsMigrate = true; } if (_dbContext.ChangeTracker.HasChanges()) { await _dbContext.SaveChangesAsync(); } _logger.LogInformation("Worker Runing"); await Task.Delay(3000, stoppingToken); } }
public static async Task AddTestData(HotelApiDbContext context) { if (context.Rooms.Any()) { //Already Has Data return; } context.Rooms.Add(new RoomEntity() { Id = Guid.NewGuid(), Name = "Driscoll Suite", Rate = 1000 }); context.Rooms.Add(new RoomEntity() { Id = Guid.Parse("f391e1b4-4e6e-4bd0-aa58-c05f0c580f17"),//Guid(61331889-41f6-4b96-8ff1-6dc090f709f1), Name = "ViewBer Mar", Rate = 2000 }); await context.SaveChangesAsync(); }
public static async Task AddTestData(HotelApiDbContext context, IDateLogicService dateLogicService) { if (context.Rooms.Any())//if it has data return { return; } var oxford = context.Rooms.Add(new RoomEntity { Id = Guid.Parse("301df04d-8679-4b1b-ab92-0a586ae53d08"), Name = "Oxford Suite", Rate = 10119, }).Entity; context.Rooms.Add(new RoomEntity { Id = Guid.Parse("ee2b83be-91db-4de5-8122-35a9e9195976"), Name = "Driscoll Suite", Rate = 23959 }); var today = DateTimeOffset.Now; var start = dateLogicService.AlignStartTime(today); var end = start.Add(dateLogicService.GetMinimumStay()); context.Bookings.Add(new BookingEntity { Id = Guid.Parse("2eac8dea-2749-42b3-9d21-8eb2fc0fd6bd"), Room = oxford, CreatedAt = DateTimeOffset.UtcNow, StartAt = start, EndAt = end, Total = oxford.Rate, }); await context.SaveChangesAsync(); }
public RoomService(HotelApiDbContext dbContext, IMapper mapper) { _dbContext = dbContext; _mapper = mapper; }
public DefaultRoomService(HotelApiDbContext context, IConfigurationProvider mappingConfiguration) { _context = context; _mappingConfiguration = mappingConfiguration; }
public DefaultRoomService(HotelApiDbContext context, IMapper mapper) { _context = context; _mapper = mapper; }
public RoomsController(HotelApiDbContext dbContext) { _dbContext = dbContext; }
public DefaultRoomService(HotelApiDbContext context) { _context = context; }
public RoomsController(HotelApiDbContext _context) { context = _context; }
public RoomServices(HotelApiDbContext context, IMapper mapper) { this._context = context; this._mapper = mapper; }
public RoomsController(HotelApiDbContext context) { _context = context; }
public RoomWorkerService(ILogger <RoomWorkerService> logger, IServiceScopeFactory scopeFactory, HotelApiDbContext dbContext) { _logger = logger; _scopeFactory = scopeFactory; _dbContext = dbContext; }
public DefaultRoomService(HotelApiDbContext context, IMapper mapper) { _context = context ?? throw new ArgumentNullException(nameof(context)); _mapper = mapper ?? throw new ArgumentNullException(nameof(mapper)); }