Ejemplo n.º 1
0
        private void SaveRentalToDataBase()
        {
            try
            {
                Rental rental = new Rental()
                {
                    From       = textBoxData,
                    To         = textBoxData.AddDays(Convert.ToInt32(TextBoxRentalDuration.Text)),
                    Cost       = CalculateCost(),
                    CustomerId = customerId,
                    CarId      = carId
                };

                try
                {
                    rentalRepository.AddRental(rental);
                    MainWindow.rentalGridData.ItemsSource = rentalRepository.GetAll();
                    ResetFields();
                    MessageBox.Show("Nowy zamówienie zostało dodane");
                }
                catch (InvalidOperationException ex)
                {
                    MessageBox.Show(ex.Message);
                }
                catch (Exception e)
                {
                    MessageBox.Show(e.ToString());
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Niestety, podane dane są nieprawidłowe - popraw je!", "", MessageBoxButton.OK,
                                MessageBoxImage.Error);
            }
        }
        private void EditRentalToDataBase()
        {
            try
            {
                Rental newRental = new Rental()
                {
                    From  = textBoxData,
                    To    = textBoxData.AddDays(rentalDuration),
                    Cost  = CalculateCost(),
                    CarId = carId
                };

                try
                {
                    rentalRepository.UpdateRental(rental.Id, newRental);
                    MainWindow.rentalGridData.ItemsSource = rentalRepository.GetAll();
                    ResetFields();
                    MessageBox.Show("Zaktualizowano zamówienie!");
                }
                catch (InvalidOperationException ex)
                {
                    MessageBox.Show(ex.Message);
                }
                catch (Exception e)
                {
                    MessageBox.Show(e.ToString());
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Niestety, podane dane są nieprawidłowe - popraw je!", "", MessageBoxButton.OK,
                                MessageBoxImage.Error);
            }
        }
Ejemplo n.º 3
0
        // GET: api/NewRentals
        public IHttpActionResult Get()
        {
            var rentalDtos = _rentalRepository.GetAll()
                             .Include(c => c.Customer)
                             .Include(m => m.Movie)
                             .ToList().Select(Mapper.Map <Rental, RentalDto>);


            return(Ok(rentalDtos));
        }
Ejemplo n.º 4
0
        // GET: Rental
        public async Task <ActionResult> Index()
        {
            RentalRepository repo = new RentalRepository();

            var viewModel = new RentalIndexViewModel()
            {
                RegistrationNumbers       = await repo.GetUniqueRegistrationNumber(),
                Rentals                   = await repo.GetAll(),
                MonthAndYearOfLastXMonths = GetMonthAndYearDictionaryOfLastMonths(12)
            };

            return(View(viewModel));
        }
Ejemplo n.º 5
0
 public List <RentalViewModel> GetAllRentals()
 {
     using (var Rentalrepo = new RentalRepository())
     {
         return(Rentalrepo.GetAll().Select(x => new RentalViewModel()
         {
             RentalId = x.RentalId,
             DateRented = x.DateRented,
             DateRequire = x.DateRequire.GetValueOrDefault(),
             ReturnDate = x.ReturnDate,
             Fine = x.Fine,
             PolicyId = x.PolicyId,
             TotalPrice = x.Totalprice,
             ItemCode = x.ItemCode,
             Quantity = x.Quantity,
         }).ToList());
     }
 }
Ejemplo n.º 6
0
 internal IEnumerable <Rental> GetAll()
 {
     return(_repo.GetAll());
 }
Ejemplo n.º 7
0
 private void PopulateRentalGrid()
 {
     rentalGrid.ItemsSource = rentalRepository.GetAll();
     rentalGridData         = rentalGrid;
 }