private void performEdit()
        {
            if (validateInputs())
            {
                var type = new CreatureType()
                {
                    CreatureTypeID = txtCreatureType.Text
                };

                try
                {
                    int result = _creatureTypeManager.UpdateCreatureType(_creatureType, type);
                    if (result != 1)
                    {
                        throw new ApplicationException("Creature Type was not updated!");
                    }
                    MessageBox.Show("Creature Type was updated!");
                    this.DialogResult = true;
                    this.Close();
                }
                catch (Exception ex)
                {
                    var message = ex.Message;
                    if (ex.InnerException != null)
                    {
                        message += "\n\n" + ex.InnerException.Message;
                    }
                    //have to display the error
                    MessageBox.Show(message, "Update Failed", MessageBoxButton.OK, MessageBoxImage.Exclamation);
                }
            }
        }
Ejemplo n.º 2
0
 public ActionResult Edit(CreatureTypeViewModel creatureTypeViewModel)
 {
     if (ModelState.IsValid)
     {
         try
         {
             var oldType = (CreatureType)(System.Web.HttpContext.Current.Session["editCreatureType"]);
             _creatureTypeManager.UpdateCreatureType(oldType, creatureTypeViewModel);
             return(RedirectToAction("Index"));
         }
         catch (Exception ex)
         {
             return(RedirectToAction("Index", "Error", new { message = ex.Message, stackTrace = ex.StackTrace }));
         }
     }
     return(View(creatureTypeViewModel));
 }