public IHttpActionResult PostNewTrade(JObject jtrade) { log4net.Config.BasicConfigurator.Configure(); log4net.ILog log = log4net.LogManager.GetLogger(typeof(Program)); Trade tradeToSave = null; try { if (jtrade == null) { throw new ArgumentNullException(); } dynamic trade = jtrade; TradeService tradeService = new TradeService(); tradeToSave = TradeParserFactory.GetTradeParser(trade.SourceApplication.Value).Parse(jtrade); var saved = tradeService.SaveTrade(tradeToSave); if (!saved) { throw new EntryPointNotFoundException(); } } catch (Exception ex) { log.Error(ex.ToString()); return(NotFound()); } return(Ok(tradeToSave)); }
public HttpResponseMessage PostNewTrade(JObject jtrade) { dynamic trade = jtrade; TradeService tradeService = new TradeService(); Trade tradeToSave = TradeParserFactory.GetTradeParser(trade.SourceApplication.Value).Parse(jtrade); tradeService.SaveTrade(tradeToSave); var response = Request.CreateResponse <Trade>(HttpStatusCode.Created, tradeToSave); string uri = Url.Link("DefaultApi", new { id = tradeToSave.Id }); response.Headers.Location = new Uri(uri); return(response); }