//BACKEND //BACKEND //BACKEND //BACKEND //BACKEND //BACKEND //BACKEND public class AppImageCrop { public IFormFile image { get; set; } public Guid ArtistID { get; set; } } public async Task OnPostSaveAppImageAsync([FromForm] AppImageCrop appImageCrop) { try { var artist = await _appDataBaseContext.Artists.SingleAsync(x => x.ArtistID == appImageCrop.ArtistID); var image = appImageCrop.image; string imageID = Guid.NewGuid().ToString(); string extention = ""; if (image == null) { } else { string uploads = Path.Combine(_env.WebRootPath, "StaticFiles", "Images"); if (image.Length > 0) { extention = Path.GetExtension(appImageCrop.image.FileName); if (!Directory.Exists(uploads)) { Directory.CreateDirectory(uploads); } string filePath = Path.Combine(uploads, imageID.ToString() + extention); using Stream fileStream = new FileStream(filePath, FileMode.Create); await image.CopyToAsync(fileStream); imageID = imageID.ToString() + extention; artist.AppCoverImage = imageID; _appDataBaseContext.Artists.Update(artist); await _appDataBaseContext.SaveChangesAsync(); } else { } } return new JsonResult(new { IsError = false, Error = "" }); } catch (Exception e) { return new JsonResult(new { IsError = true, Error = e.Message }); } }