コード例 #1
0
        public IHttpActionResult UpdateMusica(int id, DTOMusica musica)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != musica.idMusica)
            {
                return(BadRequest());
            }

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            DTOBaseResponse response = new DTOBaseResponse();

            try
            {
                BusinessLogic.Controllers.MusicaController controller = new BusinessLogic.Controllers.MusicaController();
                controller.UpdateMusica(id, musica);
                response.Success = true;
            }
            catch (Exception ex)
            {
                response.Success = false;
                response.Error   = ex.ToString();
            }
            return(Ok(response));
        }
コード例 #2
0
        public IEnumerable <DTOMusica> GetAll()
        {
            BusinessLogic.Controllers.MusicaController controller = new BusinessLogic.Controllers.MusicaController();
            List <DTOMusica> musicas = controller.GetAll();

            return(musicas);
        }
コード例 #3
0
        // GET: api/Musica/5
        public IHttpActionResult GetMusica(int id)
        {
            BusinessLogic.Controllers.MusicaController controller = new BusinessLogic.Controllers.MusicaController();
            var musica = controller.GetMusica(id);

            if (musica == null)
            {
                return(NotFound());
            }
            return(Ok(musica));
        }
コード例 #4
0
        public IHttpActionResult DeleteMusica(int id)
        {
            DTOBaseResponse response = new DTOBaseResponse();

            try
            {
                BusinessLogic.Controllers.MusicaController controller = new BusinessLogic.Controllers.MusicaController();
                controller.DeleteMusica(id);
                response.Success = true;
            }
            catch (Exception ex)
            {
                response.Success = false;
                response.Error   = ex.ToString();
            }
            return(Ok(response));
        }