/// <summary> /// Attempts to update the specified category. Prints results to console. /// </summary> /// <param name="id">The ID of the category to update</param> /// <param name="name">The new name</param> /// <param name="description">The new description</param> private static void TestUpdateCategory(int id, string name, string description) { var catService = new CategoryServiceClient(); try { Console.WriteLine(string.Format("\nAttempting to update category {0}.", id)); if (name == null) { Console.WriteLine(string.Format(" - Name = null.")); } if (description == null) { Console.WriteLine(string.Format(" - Description = null.")); } var cat = new Category { ID = id, Name = name, Description = description }; catService.UpdateCategory(cat); Console.WriteLine(string.Format(" - Category Updated: ID = {0}, Name = {1}, Description = {2}", cat.ID, cat.Name, cat.Description)); } catch (FaultException<CategoryFault> ex) { Console.WriteLine(string.Format(" - Update Exception: {0}", ex.Detail.FaultMessage)); } catch (FaultException ex) { Console.WriteLine(string.Format(" - Update Exception: {0}", ex.Message)); } }
/// <summary> /// Attempts to update the specified category. Prints results to console. /// </summary> /// <param name="id">The ID of the category to update</param> /// <param name="name">The new name</param> /// <param name="description">The new description</param> private static void TestUpdateCategory(int id, string name, string description) { var catService = new CategoryServiceClient(); try { Console.WriteLine(string.Format("\nAttempting to update category {0}.", id)); if (name == null) { Console.WriteLine(string.Format(" - Name = null.")); } if (description == null) { Console.WriteLine(string.Format(" - Description = null.")); } var cat = new Category { ID = id, Name = name, Description = description }; catService.UpdateCategory(cat); Console.WriteLine(string.Format(" - Category Updated: ID = {0}, Name = {1}, Description = {2}", cat.ID, cat.Name, cat.Description)); } catch (FaultException <CategoryFault> ex) { Console.WriteLine(string.Format(" - Update Exception: {0}", ex.Detail.FaultMessage)); } catch (FaultException ex) { Console.WriteLine(string.Format(" - Update Exception: {0}", ex.Message)); } }
public ActionResult Edit(CollectionViewModel c) { c.Category.User = new CategoryReference.UserTable() { ID = userId }; categoryObj.UpdateCategory(c.Category); return(RedirectToAction("Index")); }
private void EditCategory() { Category category = (Category)categoryDatagrid.SelectedItem; var selectedRow = categoryDatagrid.SelectedIndex; if (category != null) { try { categoryList.ElementAt(selectedRow); categoryClient.UpdateCategory(category); categoryDatagrid.Items.Refresh(); MessageBox.Show("Information updated", "Update", MessageBoxButton.OK, MessageBoxImage.Information); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Information); } } }