public async Task <ActionResult> Update(Author obj) { var resource = new AuthorPostRep { FirstName = obj.FirstName, LastName = obj.LastName, Country = obj.Country }; var response = await _proxy.PutAsync("authors/" + obj.Id, resource : resource); if (response.IsSuccessStatusCode) { AuthorViewModel model = new AuthorViewModel(); var responseList = await this._proxy.GetAsync("authors"); dynamic responseContent = await responseList.Content.ReadAsAsync <Object>(); model.Authors = responseContent.Items.ToObject <List <Author> >(); model.SelectedAuthor = obj; model.DisplayMode = "ReadOnly"; return(View("Index", model)); } return(View("Index")); }
public async Task <ActionResult> Update(Category obj) { var resource = new CategoryPostRep { Name = obj.Name, Description = obj.Description }; var response = await _proxy.PutAsync("categories/" + obj.Id, resource : resource); if (response.IsSuccessStatusCode) { CategoryViewModel model = new CategoryViewModel(); var responseList = await this._proxy.GetAsync("categories"); dynamic responseContent = await responseList.Content.ReadAsAsync <Object>(); model.Categories = responseContent.Items.ToObject <List <Category> >(); model.SelectedCategory = obj; model.DisplayMode = "ReadOnly"; return(View("Index", model)); } return(View("Index")); }
public async Task <ActionResult> Update(Book obj) { var resource = new BookPostRep { Name = obj.Name, AuthorId = obj.AuthorId, CategoryId = obj.CategoryId }; var response = await _proxy.PutAsync("books/" + obj.Id, resource : resource); if (response.IsSuccessStatusCode) { BookViewModel model = new BookViewModel(); var responseList = await this._proxy.GetAsync("books"); dynamic responseContent = await responseList.Content.ReadAsAsync <Object>(); model.Books = responseContent.Items.ToObject <List <Book> >(); model.SelectedBook = model.Books.Find(o => o.Id == obj.Id); model.DisplayMode = "ReadOnly"; return(View("Index", model)); } return(View("Index")); }