public async Task <ActionResult <Invoices> > GetInvoice(int invoiceNumber) { try { var invoice = await invoicesRepository.GetInvoice(invoiceNumber); if (invoice == null) { return(NotFound($"Invoice with number {invoiceNumber} cannopt be found")); } return(invoice); } catch (Exception) { return(StatusCode(StatusCodes.Status500InternalServerError, "Error retrieving data from database")); } }
public ViewResult Index() { List <Service> services = _sevicesRepository.GetAll().ToList(); foreach (var item in services) { item.Car = _carsrepository.GetCar(item.CarId); item.Client = _clientsRepository.GetClient(item.ClientId); item.Invoice = _invoicesRepository.GetInvoice(item.InvoiceId); } return(View(services)); }
public ViewResult Details(Guid id) { Client client = _clientsRepository.GetClient(id); List <Tuple <Car, Rent> > activerents = new List <Tuple <Car, Rent> >(); List <Tuple <Car, Rent> > finishedrents = new List <Tuple <Car, Rent> >(); foreach (var rent in _rentsRepository.GetAllRentsByClient(id)) { if (rent.IsFinished == true) { Tuple <Car, Rent> tuple = Tuple.Create(_carsRepository.GetCar(rent.CarId), rent); finishedrents.Add(tuple); } if (rent.IsActive == true && rent.IsFinished == false) { Tuple <Car, Rent> tuple = Tuple.Create(_carsRepository.GetCar(rent.CarId), rent); activerents.Add(tuple); } } List <Income> incomes = new List <Income>(); List <Invoice> expenses = new List <Invoice>(); foreach (var item in _incomesRepository.GetAllByClient(id)) { Income temp = item; temp.Invoice = _invoicesRepository.GetInvoice(temp.InvoiceId); if (temp.CarId != null) { temp.Car = _carsRepository.GetCar(temp.CarId.GetValueOrDefault()); } incomes.Add(temp); } foreach (var item in _invoicesRepository.GetAllCostByClient(id)) { expenses.Add(item); } ClientDetailsViewModel model = new ClientDetailsViewModel { Client = client, ActiveRents = activerents, FinishedRents = finishedrents, Incomes = incomes, Expenses = expenses }; return(View(model)); }
public IActionResult Details(Guid id) { var model = _invoicesRepository.GetInvoice(id); return(View(model)); }