public IActionResult Post([FromBody] Market market)
 {
     try
     {
         if (market == null)
         {
             return(StatusCode(400, StatusCodes.ReturnStatusObject("No items have been provided.")));
         }
         var result = _marketRepository.Add(market);
         if (result)
         {
             _logger.LogInformation("Market Successfully Added");
             return(StatusCode(200, StatusCodes.ReturnStatusObject("Successfully Added.")));
         }
         else
         {
             _logger.LogError("Market has Failed to Add. Market - {0}", market);
             return(StatusCode(400, StatusCodes.ReturnStatusObject("Market failed to add.")));
         }
     }
     catch (Exception e)
     {
         _logger.LogError("Error Market failed to add . Error - {0} , Data - {1}", e.Message, market);
         return(StatusCode(400, StatusCodes.ReturnStatusObject("Error Market Failed to Add." + e.Message)));
     }
 }
Esempio n. 2
0
 public int Post([FromBody] Market market)
 {
     return(_market.Add(market));
 }