Ejemplo n.º 1
0
        public HttpResponseMessage Download([FromUri] int id)
        {
            HttpResponseMessage result = null;

            try
            {
                MusicalProjectModel model  = new MusicalProjectModel();
                MemoryStream        stream = model.Download(id);

                var content = new StreamContent(stream);
                content.Headers.ContentType   = new MediaTypeHeaderValue("application/octet-stream");
                content.Headers.ContentLength = stream.GetBuffer().Length;

                result = new HttpResponseMessage(HttpStatusCode.OK)
                {
                    Content = content
                };
            }
            catch (Exception ex)
            {
                result = new HttpResponseMessage(HttpStatusCode.BadRequest);
            }

            return(result);
        }
Ejemplo n.º 2
0
        public IHttpActionResult Finish([FromUri] int id)
        {
            try
            {
                MusicalProjectModel model = new MusicalProjectModel();
                model.Finish(id);
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }

            return(Ok(new { ok = true }));
        }
Ejemplo n.º 3
0
        public IHttpActionResult Musicians(int id)
        {
            IEnumerable <Musician> musicians = null;

            try
            {
                MusicalProjectModel model = new MusicalProjectModel();
                musicians = model.Musicians(id);
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }

            return(Ok(musicians));
        }
Ejemplo n.º 4
0
        public IHttpActionResult Get([FromUri] int id)
        {
            MusicalProject project = null;

            try
            {
                MusicalProjectModel model = new MusicalProjectModel();
                project = model.Get(id);
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }

            return(Ok(project));
        }
Ejemplo n.º 5
0
        public IHttpActionResult MyProjects()
        {
            IEnumerable <MusicalProject> projects = new List <MusicalProject>();

            try
            {
                MusicalProjectModel model = new MusicalProjectModel();
                projects = model.MyProjects();
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message + ex.StackTrace));
            }

            return(Ok(projects));
        }
Ejemplo n.º 6
0
        public IHttpActionResult Contributions(int musicalProjectId, int instrumentId)
        {
            IEnumerable <Contribution> contributions = null;

            try
            {
                MusicalProjectModel model = new MusicalProjectModel();
                contributions = model.Contributions(musicalProjectId, instrumentId);
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }

            return(Ok(contributions));
        }
Ejemplo n.º 7
0
        public IHttpActionResult Instruments(int musicalProjectId)
        {
            IEnumerable <MusicalProjectInstrument> instruments = null;

            try
            {
                MusicalProjectModel model = new MusicalProjectModel();
                instruments = model.Instruments(musicalProjectId);
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }

            return(Ok(instruments));
        }
Ejemplo n.º 8
0
        public IHttpActionResult Create([FromBody] MusicalProjectModel musical_project)
        {
            MusicalProject musicalProject = null;

            try
            {
                musicalProject = musical_project.Create();
            }
            catch (ValidateException ex)
            {
                return(UnprocessableEntity(ex.Message));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }

            return(Created("api", musicalProject));
        }
Ejemplo n.º 9
0
        public IHttpActionResult SearchByMusicalGenre([FromBody] SearchByMusicalGenreObj obj)
        {
            IEnumerable <MusicalProject> projects = new List <MusicalProject>();

            try
            {
                MusicalProjectModel model = new MusicalProjectModel();
                projects = model.SearchByMusicalGenre(obj.musical_genre_id);
            }
            catch (ValidateException ex)
            {
                return(UnprocessableEntity(ex.Message));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }

            return(Ok(projects));
        }