Пример #1
0
        internal object Delete(int id)
        {
            DTOArtistGenre exists = Get(id);

            _repo.Delete(id);
            return(exists);
        }
Пример #2
0
        internal DTOArtistGenre Create(DTOArtistGenre newArtistGenre)
        {
            int id = _repo.Create(newArtistGenre);

            newArtistGenre.Id = id;
            return(newArtistGenre);
        }
Пример #3
0
        public DTOArtistGenre Get(int Id)
        {
            DTOArtistGenre exists = _repo.GetById(Id);

            if (exists == null)
            {
                throw new Exception("Invalid ArtistGenre Id");
            }
            return(exists);
        }
Пример #4
0
        internal int Create(DTOArtistGenre newArtistGenre)
        {
            string sql = @"
                INSERT INTO artistgenre
                (artistId, genreId)
                VALUES
                (@ArtistId, @GenreId);
                SELECT LAST_INSERT_ID();";

            return(_db.ExecuteScalar <int>(sql, newArtistGenre));
        }
Пример #5
0
 public ActionResult <DTOArtistGenre> Post([FromBody] DTOArtistGenre newDTOArtistGenre)
 {
     try
     {
         return(Ok(_service.Create(newDTOArtistGenre)));
     }
     catch (Exception e)
     {
         return(BadRequest(e.Message));
     }
 }