Пример #1
0
 public IActionResult GetAll()
 {
     try
     {
         var trips = _repository.GetAllTrips();
         return(Ok(Mapper.Map <IEnumerable <TripViewModel> >(trips)));
     }
     catch (Exception ex)
     {
         _logger.LogError($"Failed to get all trips fromt he database: {ex}");
         return(BadRequest("Error Occured"));
     }
 }
Пример #2
0
 public IActionResult Trips()
 {
     try
     {
         var trips       = _repo.GetAllTrips();
         var mappedTrips = Mapper.Map <IEnumerable <TripViewModel> >(trips);
         return(View(mappedTrips));
     }
     catch (Exception ex)
     {
         _logger.LogError($"Failed to get all trips in the Index page: {ex.Message}");
         return(Redirect("/error"));
     }
 }