Esempio n. 1
0
        public async Task <IHttpActionResult> PutAsync(string movieName, [FromBody] MovieFullModel newMovie)
        {
            await Task.Yield();

            if (movieName == "" || newMovie == null)
            {
                return(BadRequest("Director name can not be empty"));
            }
            try
            {
                movieService.Update(movieName, newMovie.ToEntity());
                return(Ok(newMovie));
            }
            catch (DataBaseException)
            {
                return(Content(HttpStatusCode.NotFound, $"{movieName} does not exist in our database"));
            }
        }
Esempio n. 2
0
        public async Task <IHttpActionResult> PostAsync([FromBody] MovieFullModel newMovie)
        {
            await Task.Yield();

            if (newMovie == null)
            {
                return(BadRequest("Movie can not be empty"));
            }
            try
            {
                movieService.Upload(newMovie.ToEntity());
                return(Content(HttpStatusCode.Created, $"{newMovie.Name} created"));
            }
            catch (DataBaseException)
            {
                return(Content(HttpStatusCode.Accepted, $"{newMovie.Name} already exists"));
            }
            catch (BussinesLogicException e)
            {
                return(Content(HttpStatusCode.Accepted, $"{e.Message}"));
            }
        }