public async Task <ClubFlightListViewModel> Handle(GetFlightsWithoutInvoiceQuery request, CancellationToken cancellationToken) { InvoiceToFlightComaprer comparer = new InvoiceToFlightComaprer(); ClubFlightListViewModel clubFlightListViewModel = new ClubFlightListViewModel(); var query = from b in _context.Set <Flight>() from p in _context.Set <Invoice>().Where(p => b.Id != p.InvoiceReferance && p.InvoiceType != InvoiceType.Flight) select b; //var flights = (from f in _context.Set<Flight>() // join i in _context.Set<Invoice>() on // new { IsFlight = true } // equals // new { IsFlight = !(i.InvoiceType == InvoiceType.Flight && i.InvoiceReferance > 0) } // select f); //var a = _context.Set<Flight>().Where(f => !(_context.Set<Invoice>().Select(i => i.InvoiceReferance).Contains(f.Id))); var flighInvoices = _context.Set <Invoice>().Where(i => i.InvoiceType == InvoiceType.Flight); var flightWithoutInvoice = _context.Set <Flight>().Where(f => !(flighInvoices.Select(i => i.InvoiceReferance).Contains(f.Id))).ToList(); //var noExistList = (from n in _context.Set<Flight>() // join o in _context.Set<Invoice>() on n.Id equals o.InvoiceReferance // where o.InvoiceType == InvoiceType.Flight // select n).ToList(); ClubFlightModel clubFlightViewModel = new ClubFlightModel(); clubFlightListViewModel.clubFlightListViewModel = _mapper.Map <List <Flight>, List <ClubFlightModel> >(flightWithoutInvoice); return(clubFlightListViewModel); }
public async Task Put([FromBody] ClubFlightModel value) { CreateFlightCommand createFlightCommand = new CreateFlightCommand(); createFlightCommand.ClubFlightModel = value; createFlightCommand.ClubId = 1; var result = _mediator.Send(createFlightCommand); }
public async Task Post([FromBody] ClubFlightModel value) { UpdateFlightCommand updateFlightCommand = new UpdateFlightCommand(); updateFlightCommand.ClubFlightViewModel = value; var ressult = _mediator.Send(updateFlightCommand); return; }
public async Task <ClubFlightModel> Get(int id) { Flight flight; ClubFlightModel clubFlightModel = new ClubFlightModel(); //var flightlist = await _clubService.GetClubAircraftFlight("BAZ", 8); //flight = flightlist.Where(i => i.Id == id).FirstOrDefault(); //clubFlightModel = _mapper.Map<Flight, ClubFlightModel>(flight); //if (clubFlightModel.Routh == null) // clubFlightModel.Routh = "NULL"; return(clubFlightModel); }
public async Task <FlightRecordIndexModel> Handle(GetAllFlightsQuery request, CancellationToken cancellationToken) { InvoiceToFlightComaprer comparer = new InvoiceToFlightComaprer(); FlightRecordIndexModel flightRecordIndexViewModel = new FlightRecordIndexModel(); var flights = _context.Set <Flight>().ToList(); ClubFlightModel clubFlightViewModel = new ClubFlightModel(); flightRecordIndexViewModel.FlightRecords = _mapper.Map <List <Flight>, List <ClubFlightModel> >(flights); int totalFlight = flights.Count(); flightRecordIndexViewModel.PaginationInfo.TotalItems = totalFlight; flightRecordIndexViewModel.PaginationInfo.ActualPage = 1; flightRecordIndexViewModel.PaginationInfo.TotalItems = totalFlight; flightRecordIndexViewModel.PaginationInfo.TotalPages = int.Parse(Math.Ceiling((decimal)totalFlight / flightRecordIndexViewModel.PaginationInfo.ItemsPerPage).ToString()); flightRecordIndexViewModel.PaginationInfo.Next = flightRecordIndexViewModel.PaginationInfo.ActualPage >= flightRecordIndexViewModel.PaginationInfo.TotalPages ? "disabled" : ""; flightRecordIndexViewModel.PaginationInfo.Previous = flightRecordIndexViewModel.PaginationInfo.ActualPage == 1 ? "disabled" : ""; return(flightRecordIndexViewModel); }