public async Task <IHttpActionResult> Post() { // Check if the request contains multipart/form-data. if (!Request.Content.IsMimeMultipartContent("form-data")) { return(BadRequest("Unsupported media type")); } try { //var pictures = await _pictureManager.Add(Request); var pictures = await _pictureManager.GetImagebyte(Request); Image image = new Image(); image.Photo = pictures; _dbContext.Image.Add(image); _dbContext.SaveChanges(); int newId = image.ImageId; return(Ok(new { Message = "pictures uploaded ok", newId })); } catch (Exception ex) { return(BadRequest(ex.GetBaseException().Message)); } }