Exemplo n.º 1
0
        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());
        }
Exemplo n.º 2
0
 public Suggestion CreateSuggetion(Suggestion newSuggestion)
 {
     _suggestionContext.Add(newSuggestion);
     _suggestionContext.SaveChanges();
     return(newSuggestion);
 }