public async Task <ActionResult> Create(HortaBindingModel horta) { var model = new HortaDataModel() { Titulo = horta.Titulo, Descricao = horta.Descricao, PerfilId = horta.PerfilId }; try { HttpFileCollectionBase files = Request.Files; int fileCount = files.Count; await _blobHelper.SetupCloudBlob(connectionString); var blob = _blobHelper._blobCointainer.GetBlockBlobReference(_blobHelper.GetRandomBlobName(files[0].FileName)); await blob.UploadFromStreamAsync(files[0].InputStream); model.Foto = blob.StorageUri.PrimaryUri.ToString(); await _clientHelper.PostHortaAsync(model); return(RedirectToAction("Index")); } catch { return(View()); } }
// HortaHelper #region public async Task <HttpResponseMessage> PostHortaAsync(HortaDataModel model) { return(await _client.PostAsJsonAsync("api/Horta/Post", model)); }
public async Task <HttpResponseMessage> PutHortaAsync(int id, HortaDataModel model) { return(await _client.PutAsJsonAsync($"api/Horta/{id}", model)); }