static void Main(string[] args) { var connectionString = ConfigurationManager.ConnectionStrings["HostelDbConnection"].ConnectionString; IRoomsRepository roomRepository = new RoomsRepository(connectionString); IGuestsRepository guestsRepository = new GuestsRepository(connectionString); var id = 2; var res = roomRepository.GetById(id); var romById = roomRepository.GetById(3); var guests = guestsRepository.GetAll(); var wasRoomCreated = roomRepository.Create(new RoomsDal() { Floor = 5, RoomLetter = null, RoomNumber = 514, RoomType = new RoomTypesDal() { Id = 2, } }); var rooms = roomRepository.GetAll(); var activeGuests = guestsRepository.GetGuestsFromTimePeriod(DateTime.Now, DateTime.Now); var guestById = guestsRepository.GetById(2); Console.WriteLine($"RoomNumber: {res.RoomNumber} {res.RoomLetter ?? String.Empty}"); Console.ReadLine(); }
protected override void OnStartup(StartupEventArgs e) { HibernatingRhinos.Profiler.Appender.EntityFramework.EntityFrameworkProfiler.Initialize(); base.OnStartup(e); //главный контекст MainContext = new MainEntititesContext(); //Стартовое окно выбора отеля var hotelsRepository = new HotelsRepository(MainContext); var startWindowViewModel = new StartWindowViewModel(hotelsRepository); var startWindow = new StartWindow() { DataContext = startWindowViewModel }; startWindow.Show(); //подписка на событие выбора отеля startWindowViewModel.StartButtonClicked += () => { MainContext.CurrentHotel = startWindowViewModel.SelectedHotel; //--Создание репозитеориев с данными var guestsRepository = new GuestsRepository(MainContext); var roomsRepository = new RoomsRepository(MainContext); var typesRepository = new TypeOfRoomsRepository(MainContext); var registrationRepository = new RegistrationRepository(MainContext); var registrationViewRepository = new RegistrationViewRepository(MainContext); var paymentsRepository = new PaymentsRepository(MainContext); var paymentsViewRepository = new PaymentsViewRepository(MainContext); var wishesRepository = new WishesRepository(MainContext); var discountsRepository = new DiscountsRepository(MainContext); var guestsDiscountsRepository = new GuestsDiscountsRepository(MainContext); var servicesRepository = new ServicesRepository(MainContext); var realizationRepository = new ServiceRealizationRepository(MainContext); //создание модели представления главного окна var mainviewmodel = new MainWindowViewModel(hotelsRepository, guestsRepository, roomsRepository, typesRepository, registrationViewRepository, registrationRepository, paymentsRepository, paymentsViewRepository, wishesRepository, discountsRepository, guestsDiscountsRepository, servicesRepository, realizationRepository); //создание представления главного окна var mainview = new MainWindow() { DataContext = mainviewmodel }; mainview.Show(); startWindowViewModel = null; startWindow.Close(); }; }
//public HostEventController(HostEventsRepository eventsRepository, HostEventsHelper hostEventsHelper, UserManager<IdentityUser> userManager, GiftsRepository giftsRepository, GuestsRepository guestsRepository) public HostEventController(HostEventsRepository eventsRepository, RoleManager <IdentityRole> roleManager, UserManager <IdentityUser> userManager, GiftsRepository giftsRepository, GuestsRepository guestsRepository) { _hostEventsRepository = eventsRepository; //_hostEventsHelper = hostEventsHelper; _userManager = userManager; _giftsRepository = giftsRepository; _guestsRepository = guestsRepository; _roleManager = roleManager; }
static void Main(string[] args) { var builder = new ConfigurationBuilder() .SetBasePath(Directory.GetCurrentDirectory()) .AddJsonFile("appsettings.json"); Configuration = builder.Build(); string banjoConnectionString = Configuration.GetConnectionString("banjo"); Console.WriteLine(banjoConnectionString); var optionsBuilder = new DbContextOptionsBuilder <BanjoContext>(); optionsBuilder.UseSqlServer(banjoConnectionString); var banjoContext = new BanjoContext(optionsBuilder.Options); var repository = new GuestsRepository(banjoContext); if (!args.Any()) { Console.WriteLine("Required Argument: Excel File For Import"); return; } string fileName = $"{Directory.GetCurrentDirectory()}\\{args[0]}"; Console.WriteLine($"Reading: {fileName}"); //Create COM Objects. Create a COM object for everything that is referenced XSSFWorkbook workbook = new XSSFWorkbook(fileName); ISheet sheet = workbook.GetSheetAt(0); var guestList = new List <Guest>(); for (int i = 0; i <= sheet.LastRowNum; ++i) //Loop the records upto filled row { IRow row = sheet.GetRow(i); if (row != null) //null is when the row only contains empty cells { //PrintGuest(row.ToEntity()); guestList.Add(row.ToEntity()); } } var task = Task.Run(async() => { await repository.Add(guestList); }); Task.WaitAll(task); Console.WriteLine("Finished, Cleaning up!"); }
public int NewGuest(AddGuestCommand addGuestCommand) { var repo = new GuestsRepository(); return(repo.AddGuest(addGuestCommand)); }
public ActionResult <IEnumerable <Guests> > AllGuests() { var repo = new GuestsRepository(); return(repo.GetAllGuests()); }
public GuestController(GuestsRepository guestsRepository, UserManager <IdentityUser> userManager) { _guestsRepository = guestsRepository; _userManager = userManager; }