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); } }
// 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)); }
// 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)); }
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()); } }
internal IEnumerable <Rental> GetAll() { return(_repo.GetAll()); }
private void PopulateRentalGrid() { rentalGrid.ItemsSource = rentalRepository.GetAll(); rentalGridData = rentalGrid; }