public UnitOfWork(LuaContext context) { _context = context; Authors = new AuthorRepository(_context); Books = new BookRepository(_context); Customers = new CustomerRepository(_context); Rentals = new RentalRepository(_context); Stocks = new StockRepository(_context); }
public async void Test_Repository_GetAsync_ById() { await _connection.OpenAsync(); try { using (var ctx = new LodgingContext(_options)) { await ctx.Database.EnsureCreatedAsync(); } using (var ctx = new LodgingContext(_options)) { var lodgings = new LodgingRepository(ctx); var actual = await lodgings.GetAsync(1); Assert.Null(actual); } using (var ctx = new LodgingContext(_options)) { var rentals = new RentalRepository(ctx); var actual = await rentals.GetAsync(1); Assert.Null(actual); } using (var ctx = new LodgingContext(_options)) { var reviews = new ReviewRepository(ctx); var actual = await reviews.GetAsync(1); Assert.Null(actual); } } finally { await _connection.CloseAsync(); } }
public async void Test_RentalRepo_GetAsync() { var dbOptions = await NewDb(); using (var ctx = new LodgingContext(dbOptions)) { await ctx.Database.EnsureCreatedAsync(); await ctx.SaveChangesAsync(); } using (var ctx = new LodgingContext(dbOptions)) { var repo = new RentalRepository(ctx); var actual = await repo.GetAsync(new RentalQueryParamsModel()); Assert.Empty(actual); } }
public RentalViewModel Search(string id) { using (var i = new RentalRepository()) { Rental obj = i.GetById(id); var itm = new RentalViewModel(); itm.RentalId = obj.RentalId; itm.DateRented = obj.DateRented.GetValueOrDefault(); itm.DateRequire = obj.DateRequire.GetValueOrDefault(); itm.ReturnDate = obj.ReturnDate; itm.Fine = obj.Fine; itm.PolicyId = obj.PolicyId; itm.TotalPrice = obj.Totalprice; itm.ItemCode = obj.ItemCode; itm.Quantity = obj.Quantity; return(itm); } }
public RentalViewModel GetRentalById(string id) { using (var Rental = new RentalRepository()) { Rental itm = Rental.GetById(id); var itmViewModel = new RentalViewModel(); if (itm != null) { itmViewModel.RentalId = itm.RentalId; itmViewModel.DateRented = itm.DateRented.GetValueOrDefault(); itmViewModel.DateRequire = itm.DateRequire.GetValueOrDefault(); itmViewModel.ReturnDate = itm.ReturnDate; itmViewModel.Fine = itm.Fine; itmViewModel.PolicyId = itm.PolicyId; itmViewModel.TotalPrice = itm.Totalprice; itmViewModel.ItemCode = itm.ItemCode; itmViewModel.Quantity = itm.Quantity; } return(itmViewModel); } }
public void UpdateRental(RentalViewModel model) { using (var Rental = new RentalRepository()) { Rental itm = Rental.GetById(model.RentalId); if (itm != null) { itm.RentalId = model.RentalId; itm.DateRented = model.DateRented; itm.DateRequire = model.DateRequire; itm.ReturnDate = DateTime.Now; itm.Fine = model.Fine; itm.PolicyId = model.PolicyId; itm.Totalprice = model.TotalPrice; itm.ItemCode = model.ItemCode; itm.Quantity = model.Quantity; Rental.Update(itm); } } }
public void RemoveRentalTest() { MemberRepository memberRepository = new MemberRepository(); Member member = new Member { Name = "Test2", PhoneNumber = 091220047 }; memberRepository.AddMember(member); RentalRepository rentalRepository = new RentalRepository(); Rental expectedRental = new Rental { Member = member }; var id = rentalRepository.AddRental(expectedRental); rentalRepository.DeleteRental(id); rentalRepository.GetRentalById(id); }
/// <summary> /// Inicjalizuje obiekt AddRentalView oraz inicjalizuje RentalRepository oraz CarRepository użyte w klasie. /// </summary> public AddRentalView() { InitializeComponent(); rentalRepository = new RentalRepository(); carRepository = new CarRepository(); }
static void Main() { WindowsFormsFactory formsFactory = new WindowsFormsFactory(); MainFormController mainController = new MainFormController(formsFactory, BoardGameRepository.GetInstance(), MemberRepository.GetInstance(), UserRepository.GetInstance(), RentalRepository.GetInstance()); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new frmLogin(mainController)); }
public RentalService() { var videoClubDi = new VideoClubDi(VideoClubContext.GetVideoClubContext()); _rentalRepository = new RentalRepository(videoClubDi); }
public async void Test_Repository_Update(LodgingModel lodging, RentalModel rental, ReviewModel review) { await _connection.OpenAsync(); try { using (var ctx = new LodgingContext(_options)) { await ctx.Database.EnsureCreatedAsync(); await ctx.Lodgings.AddAsync(lodging); await ctx.Rentals.AddAsync(rental); await ctx.Reviews.AddAsync(review); await ctx.SaveChangesAsync(); } using (var ctx = new LodgingContext(_options)) { var lodgings = new LodgingRepository(ctx); var expected = await ctx.Lodgings.FirstAsync(); expected.Name = "name"; lodgings.Update(expected); await ctx.SaveChangesAsync(); var actual = await ctx.Lodgings.FirstAsync(); Assert.Equal(expected, actual); } using (var ctx = new LodgingContext(_options)) { var rentals = new RentalRepository(ctx); var expected = await ctx.Rentals.FirstAsync(); expected.Name = "name"; rentals.Update(expected); await ctx.SaveChangesAsync(); var actual = await ctx.Rentals.FirstAsync(); Assert.Equal(expected, actual); } using (var ctx = new LodgingContext(_options)) { var reviews = new ReviewRepository(ctx); var expected = await ctx.Reviews.FirstAsync(); expected.Comment = "comment"; reviews.Update(expected); await ctx.SaveChangesAsync(); var actual = await ctx.Reviews.FirstAsync(); Assert.Equal(expected, actual); } } finally { await _connection.CloseAsync(); } }
public RentalService(IMapper mapper) { _rentalRepository = new RentalRepository(mapper); _ownerRepository = new OwnerRepository(mapper); }
public IActionResult OnPost() { Rental.Renter = Renter; RentalRepository.CreateRental(Rental); return(Redirect($"~/RenterDetails/{Renter.Id}")); }
public void OnGet(int id) { Renter = RenterRepository.GetRenter(id); Renter.Rentals = RentalRepository.GetRentalsFor(Renter.Id); Equipments = EquipmentRepository.GetEquipments(); }
public RentalRepositoryTests() { newAccount = CreateNewAccount(); rental = CreateRental(); rentalRepository = GetInMemoryRentalRepository(); }
public void OnGet(int id) { Renter = RenterRepository.GetById(id); Rentals = RentalRepository.GetByRenterId(id); Renter.Rentals = Rentals; }
public RentalsService(RentalRepository repo) { _repo = repo; }
public void OnPostInsert() { RentalRepository.Insert(Rental); Rentals = RentalRepository.GetByRenterId(Rental.Renter.Id); }
public RentalController() { m_rentalRepository = new RentalRepository(); m_gameRepository = new GameRepository(); }
public void TestSetup() { _repo = new RentalRepository(); _bike = new Bike(); _person = new Person(); }