public async Task <ActionResult> Edit(int id) { HttpClient httpClient = ClientFactory.CreateClient("Project1Api"); var client = new ModelObjectClient(httpClient); var fetchedGift = await client.GetAsync(id); return(View(fetchedGift)); }
//private ModelObjectClient Client { get; } public async Task <ActionResult> Index() { //ICollection<ModelObject> modelObjects = await Client.GetAllAsync(); //return View(modelObjects); HttpClient httpClient = ClientFactory.CreateClient("Project1Api"); var client = new ModelObjectClient(httpClient); ICollection <ModelObject> modelObjects = await client.GetAllAsync(); return(View(modelObjects)); }
public async Task <ActionResult> Create(ModelObjectInput modelObjectInput) { ActionResult result = View(modelObjectInput); if (ModelState.IsValid) { HttpClient httpClient = ClientFactory.CreateClient("Project1Api"); var client = new ModelObjectClient(httpClient); var createdAuthor = await client.PostAsync(modelObjectInput); result = RedirectToAction(nameof(Index)); } return(result); }
public async Task <ActionResult> Upload(int id, [FromForm] IFormFile fileInput) { HttpClient httpClient = ClientFactory.CreateClient("Project1Api"); IStorageService storageService = new StorageServiceS3("ded20b31-0bf4-4d39-8d1f-9b8aba09cb38"); MemoryStream streamMem = new MemoryStream(); fileInput.CopyTo(streamMem); streamMem.Seek(0, SeekOrigin.Begin); (string urlPut, string urlGet, DateTime expiration)accessCredentials = await storageService.UploadStreamLimited(streamMem, fileInput.ContentType, fileInput); var client = new ModelObjectClient(httpClient); await client.Put2Async(id, accessCredentials.urlGet, accessCredentials.expiration); return(RedirectToAction(nameof(Index))); }