public async Task <IActionResult> OnPost() { // Make the call to our DB with our ID. Restaurant rest = await _restaurant.FindRestaurant(ID.GetValueOrDefault()) ?? new Restaurant(); // set the data from the database to the new data from Restaurant/user input rest.Name = Restaurant.Name; rest.Description = Restaurant.Description; rest.StarRating = Restaurant.StarRating; if (Image != null) { // Do all of our Azure Blob stuffs var filePath = Path.GetTempFileName(); using (var stream = new FileStream(filePath, FileMode.Create)) { await Image.CopyToAsync(stream); } // Get Container var container = await BlobImage.GetContainer("restaurant"); // upload the image BlobImage.UploadFile(container, Image.FileName, filePath); // Get the image that we just uploaded CloudBlob blob = await BlobImage.GetBlob(Image.FileName, container.Name); // update the db image for the restaurant rest.URL = blob.Uri.ToString(); } // Save the restaurant in the database await _restaurant.SaveAsync(rest); return(RedirectToPage("/Restaurants/Index", new { id = rest.ID })); }