public List <TicketTypeRowViewModel> GetTicketTypesByVehicleId(int vehicleId, string ticketTypeName) { ticketTypeName = ticketTypeName ?? ""; List <TicketType> ticketTypes = null; if (vehicleId == -1) { ticketTypes = _ticketTypeRepository.GetAllQueryable() .Where(x => x.Name.ToLower().Contains(ticketTypeName.ToLower())) .Where(x => x.Deleted == false) .ToList(); } else { ticketTypes = _ticketTypeRepository.GetAllQueryable() .Where(x => x.VehicleId == vehicleId) .Where(x => x.Name.ToLower().Contains(ticketTypeName.ToLower())) .Where(x => x.Deleted == false) .ToList(); } var ticketTypeRowVMs = _mapper.Map <List <TicketType>, List <TicketTypeRowViewModel> >(ticketTypes); return(ticketTypeRowVMs); }