コード例 #1
0
ファイル: UnitOfWork.cs プロジェクト: raduaron26/Lua
 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);
 }
コード例 #2
0
        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();
            }
        }
コード例 #3
0
        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);
            }
        }
コード例 #4
0
        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);
            }
        }
コード例 #5
0
 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);
     }
 }
コード例 #6
0
        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);
                }
            }
        }
コード例 #7
0
        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);
        }
コード例 #8
0
 /// <summary>
 /// Inicjalizuje obiekt AddRentalView oraz inicjalizuje RentalRepository oraz CarRepository użyte w klasie.
 /// </summary>
 public AddRentalView()
 {
     InitializeComponent();
     rentalRepository = new RentalRepository();
     carRepository    = new CarRepository();
 }
コード例 #9
0
        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));
        }
コード例 #10
0
        public RentalService()
        {
            var videoClubDi = new VideoClubDi(VideoClubContext.GetVideoClubContext());

            _rentalRepository = new RentalRepository(videoClubDi);
        }
コード例 #11
0
        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();
            }
        }
コード例 #12
0
 public RentalService(IMapper mapper)
 {
     _rentalRepository = new RentalRepository(mapper);
     _ownerRepository  = new OwnerRepository(mapper);
 }
コード例 #13
0
 public IActionResult OnPost()
 {
     Rental.Renter = Renter;
     RentalRepository.CreateRental(Rental);
     return(Redirect($"~/RenterDetails/{Renter.Id}"));
 }
コード例 #14
0
 public void OnGet(int id)
 {
     Renter         = RenterRepository.GetRenter(id);
     Renter.Rentals = RentalRepository.GetRentalsFor(Renter.Id);
     Equipments     = EquipmentRepository.GetEquipments();
 }
コード例 #15
0
 public RentalRepositoryTests()
 {
     newAccount       = CreateNewAccount();
     rental           = CreateRental();
     rentalRepository = GetInMemoryRentalRepository();
 }
コード例 #16
0
 public void OnGet(int id)
 {
     Renter         = RenterRepository.GetById(id);
     Rentals        = RentalRepository.GetByRenterId(id);
     Renter.Rentals = Rentals;
 }
コード例 #17
0
ファイル: RentalsService.cs プロジェクト: KrisJones91/vacay
 public RentalsService(RentalRepository repo)
 {
     _repo = repo;
 }
コード例 #18
0
 public void OnPostInsert()
 {
     RentalRepository.Insert(Rental);
     Rentals = RentalRepository.GetByRenterId(Rental.Renter.Id);
 }
コード例 #19
0
 public RentalController()
 {
     m_rentalRepository = new RentalRepository();
     m_gameRepository   = new GameRepository();
 }
コード例 #20
0
 public void TestSetup()
 {
     _repo   = new RentalRepository();
     _bike   = new Bike();
     _person = new Person();
 }