public IActionResult Create([FromBody] SuggestionDto suggestionDto) { if (ModelState.IsValid) { if (RecaptchaResponseIsValid(suggestionDto.Recaptcha)) { Suggestion suggestion = new Suggestion(); suggestion.SubmitterName = suggestionDto.SubmitterName; suggestion.SongName = suggestionDto.SongName; suggestion.ArtistName = suggestionDto.ArtistName; suggestion.Added = DateTime.Now; suggestion.IsActive = true; _context.Suggestions.Add(suggestion); _context.SaveChanges(); return(Ok(suggestion)); } } return(BadRequest()); }
public Suggestion CreateSuggetion(Suggestion newSuggestion) { _suggestionContext.Add(newSuggestion); _suggestionContext.SaveChanges(); return(newSuggestion); }