public async Task <string> UpdateProductAsync(ProductAndCategoryBase item) { string uri = $"{ProductBaseUri}/{item.Id}"; var json = JsonConvert.SerializeObject(item); return(await SubmitPutRequestAsync(uri, json)); }
public async Task <IActionResult> AddPost(ProductAndCategoryBase item) { try { await _webApiCalls.AddProductAsync(item.CategoryId, item.Description, item.ModelName, item.ModelNumber, item.ProductImage, item.ProductImageLarge, item.ProductImageThumb, item.UnitCost, item.CurrentPrice, item.UnitsInStock, item.IsFeatured); } catch (Exception ex) { ModelState.AddModelError(string.Empty, "There was an error adding the product."); } return(RedirectToAction(nameof(Index))); }
public async Task <IActionResult> Update(int id, string timeStampString, ProductAndCategoryBase item) { item.TimeStamp = JsonConvert.DeserializeObject <byte[]>($"\"{timeStampString}\""); try { await _webApiCalls.UpdateProductAsync(item); } catch (Exception ex) { ModelState.AddModelError(string.Empty, "An error occurred updating the product."); } return(RedirectToAction(nameof(Index))); }
public async Task <IActionResult> Delete(int id, ProductAndCategoryBase item) { await _webApiCalls.RemoveProductAsync(id, item.TimeStamp); return(RedirectToAction(nameof(Index))); }