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.")); }
public async Task <bool> UpdatePhotoAsync(ES_DN_Photo photo) { var resp = await _client.IndexDocumentAsync(photo); return(resp.IsValid); }