// ADD NEW TRADE LIST // public TradeList AddNewTradeList(CreateTradeListRequest createRequest) { createRequest.Loose = System.Convert.ToDecimal(createRequest.Loose); using (var db = new SqlConnection(ConnectionString)) { var newTradeListQuery = @" INSERT INTO [Tradelist] (UserId, CartId, Name, Genre, ReleaseDate, ImageUrl, Loose, productId) OUTPUT Inserted.* VALUES(@UserId, @CartId, @name, @genre, @releaseDate, @imageUrl, @loose, @productId)"; var MyNewTradeList = db.QueryFirstOrDefault <TradeList>(newTradeListQuery, new { createRequest.UserId, createRequest.CartId, createRequest.Name, createRequest.Genre, createRequest.ReleaseDate, createRequest.ImageUrl, createRequest.Loose, createRequest.ProductId, }); if (MyNewTradeList != null) { return(MyNewTradeList); } } throw new Exception("NESVault Trade List Not Created"); }
public ActionResult AddMyTradeList(CreateTradeListRequest createRequest) { var newTradeList = _tradeListRepository.AddNewTradeList(createRequest); if (newTradeList == null) { return(BadRequest(new { error = "NESVault Requests You Fill All Necessary Fields." })); } else { return(Created($"api/tradelist/{newTradeList.Id}", newTradeList)); } }