public async Task <IActionResult> ImageReady(ThisShouldNotExist textBody) { if (textBody == null || textBody.TextBody == null) { return(BadRequest("No url provided")); } var url = textBody.TextBody; var pic = await _dataAccess.GetPictureByUrlAsync(url); if (pic != null) { string filename = pic.OriginalName ?? pic.Name; filename = filename.Replace('_', '-').Replace('.', '-'); var user = await _userManager.FindByIdAsync(pic.User_Id); bool result = await _caching.InsertPhotoAsync(pic); ES_DN_Photo photo = new ES_DN_Photo { PhotoId = pic.Id, User = new ES_DN_User { Email = user.Email, UserName = user.UserName, UserId = user.Id }, Data = new ES_DN_Data { Name = filename, Thumbnail_Url = pic.Thumbnail_Url, TotalRating = pic.Total_Rating, Url = pic.Url, Votes = pic.Votes } }; result = await _search.InsertPhotoAsync(photo); return(NoContent()); } return(NotFound($"The {url} was not found on this server.")); }
//I made the class test because with it the binding works, i have tried many things but none of them have worked //for example (int commentId, [FromBody] string textBody) public async Task <IActionResult> UpdateComment(int commentId, ThisShouldNotExist textBody) { var comment = await _dataAccess.GetCommentAsync(commentId); if (comment == null) { return(NotFound()); } if (comment.Email != User.Identity.Name) { return(Forbid()); } if (textBody == null) { return(BadRequest()); } comment.Text = textBody.TextBody; await _dataAccess.UpdateCommentAsync(comment); return(NoContent()); }