public IHttpActionResult Get(int id) { try { var tran = Factory.CreateViewRestaurantTransaction(id); tran.Execute(); if (tran.Response.WasSucessfull) { var rest = ViewModelMapper.ConvertDomainRestaurantToViewModel(id, tran); return(Ok(rest)); } return(BadRequest()); } catch (RestaurantNotFoundException) { return(NotFound()); } catch (Exception ex) { Logger.ErrorLog($"Web API failed getting restaurant id {id}", ex); return(InternalServerError()); } }
public IHttpActionResult Get() { try { var tran = Factory.CreateViewAllRestaurantsTransaction(); tran.Execute(); if (tran.Response.WasSucessfull) { var allRestaurants = ViewModelMapper.ConvertDomainRestaurantGroupToViewModel(tran.Response.Restaurants); return(Ok(allRestaurants)); } else { return(BadRequest()); } } catch (Exception ex) { Logger.ErrorLog("Unable to fetch valid restaurants", ex); return(InternalServerError()); } }