public object GetService(Type serviceType) { try { return(container.Resolve(serviceType)); } catch (ResolutionFailedException ex) { WebApiExceptionHandler.HandleException(ex); return(null); } }
public async Task <IHttpActionResult> GetByPolicyNumber(string policyId) { try { var client = await _clientService.GetByPolicyNumber(policyId); if (client != null) { return(Ok(client)); } return(NotFound()); } catch (Exception ex) { WebApiExceptionHandler.HandleException(ex); return(NotFound()); } }
public async Task <IHttpActionResult> GetByName(string name) { try { var client = await _clientService.GetByUserAsync(name); if (client != null) { return(Ok(client)); } return(NotFound()); } catch (Exception ex) { WebApiExceptionHandler.HandleException(ex); return(NotFound()); } }
public async Task <IHttpActionResult> Get() { try { var clients = await _clientService.GetAllAsync(); if (clients != null) { return(Ok(clients)); } return(NotFound()); } catch (Exception ex) { WebApiExceptionHandler.HandleException(ex); return(NotFound()); } }
public static void Register(HttpConfiguration config) { // Web API configuration and services log4net.Config.XmlConfigurator.Configure(); // Web API routes config.MapHttpAttributeRoutes(new CustomDirectRouteProvider()); config.Routes.MapHttpRoute( name: "DefaultApi", routeTemplate: "api/{controller}/{action}/{id}", defaults: new { id = RouteParameter.Optional } ); config.Formatters.Insert(0, new TextMediaTypeFormatter()); // Setup exception handling filter WebApiExceptionHandler.SetupExceptionHandlers(); }