Exemple #1
0
        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());
        }
Exemple #2
0
        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());
        }