public IActionResult Post(StockExchangeDto se) { if (ModelState.IsValid) { var isAdded = repository.Add(se); if (isAdded) { return(Created("Following Stock Exchange was added", se)); } return(StatusCode(500, "Internal Server Error, Stock Exchange couldn't be added")); } return(BadRequest(ModelState)); }
public IActionResult AddStockExchange(StockExchangeDto stockExchange) { if (ModelState.IsValid == false) { return(BadRequest(ModelState)); } var result = service.AddStockExchange(stockExchange); if (!result) { return(BadRequest("Error saving Stock Exchange")); } //return CreatedAtRoute("GetProductById", new { id = obj.ID }); return(StatusCode(201)); }
public bool AddStockExchange(StockExchangeDto stockExchange) { var Obj = mapper.Map <StockExchange>(stockExchange); return(repository.AddStockExchange(Obj)); }