public HttpResponseMessage AddUpdateMovie() { try { var movieID = HttpContext.Current.Request.Form["MovieID"]; var name = HttpContext.Current.Request.Form["Name"]; var yearOfRelease = HttpContext.Current.Request.Form["YearOfRelease"]; var plot = HttpContext.Current.Request.Form["Plot"]; var producerID = HttpContext.Current.Request.Form["ProducerID"]; var actors = HttpContext.Current.Request.Form["Actors"].Split(',').Select(s => Convert.ToInt32(s)).ToArray(); var fileData = HttpContext.Current.Request.Files["file"]; byte[] data = null; string ContentType = string.Empty; if (fileData != null && fileData.ContentLength > 0) { MemoryStream target = new MemoryStream(); fileData.InputStream.CopyTo(target); data = target.ToArray(); ContentType = fileData.ContentType; } MovieModel movieModel = new MovieModel(); movieModel.MovieID = Convert.ToInt32(movieID); movieModel.Name = name; movieModel.YearOfRelease = Convert.ToInt16(yearOfRelease); movieModel.Plot = plot; movieModel.ProducerID = Convert.ToInt32(producerID); movieModel.Actors = actors; if (!string.IsNullOrEmpty(ContentType) && data.Length > 0) { movieModel.Poster = new Base64Image(ContentType, data).ToString(); movieModel.ContentType = ContentType; } return(Request.CreateResponse <bool>(HttpStatusCode.OK, _MoviesReposotory.AddUpdateMovie(movieModel))); } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.Message.ToString() + "Error occured while executing api method")); } }