public IActionResult Post([FromBody] Quote objQuotes) { string userId = User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.NameIdentifier).Value; objQuotes.UserId = userId; _dbContext.Quotes.Add(objQuotes); _dbContext.SaveChanges(); return(StatusCode(StatusCodes.Status201Created)); }
// POST: api/Quotes public IHttpActionResult Post([FromBody] Quote quote) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } quotesDBContext.Quotes.Add(quote); quotesDBContext.SaveChanges(); return(StatusCode(HttpStatusCode.Created)); }
public void Add(Quote quote) { _context.Add <Quote>(quote); _context.SaveChanges(); }
public IActionResult Post([FromBody] Quote quote) { quotesDBContext.Quotes.Add(quote); quotesDBContext.SaveChanges(); return(StatusCode(StatusCodes.Status201Created)); }