public ActionResult CreateNewFile(int genre_id, String title, String format, String file_path) { var genre = _context.Genres.Find(genre_id); if (genre == null) { return(NotFound("Genre was not found.")); } var file = new File { GenreId = genre_id, Title = title, Format = format, FilePath = file_path }; try { _context.Files.Add(file); _context.SaveChanges(); } catch (Exception ex) { return(BadRequest(ex.Message)); } return(Ok()); }
public ActionResult CreateNewGenre(String name) { var genre = new Genre { Name = name }; try { _context.Genres.Add(genre); _context.SaveChanges(); } catch (Exception ex) { return(BadRequest(ex.Message)); } return(Ok()); }