Example #1
0
        public ActionResult Create(CreatureTypeViewModel creatureTypeViewModel)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    _creatureTypeManager.AddCreatureType(creatureTypeViewModel);
                    return(RedirectToAction("Index"));
                }
                catch (Exception ex)
                {
                    return(RedirectToAction("Index", "Error", new { message = ex.Message, stackTrace = ex.StackTrace }));
                }
            }

            return(View(creatureTypeViewModel));
        }
Example #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));
 }
Example #3
0
 // GET: CreatureType/Delete/5
 public ActionResult Delete(string id)
 {
     if (id == null)
     {
         return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
     }
     try
     {
         CreatureType          creatureType          = _creatureTypeManager.RetreiveCreatureTypeByID(id);
         CreatureTypeViewModel creatureTypeViewModel = new CreatureTypeViewModel
         {
             DisplayCreatureTypeID = creatureType.CreatureTypeID,
             Active = creatureType.Active
         };
         return(View(creatureTypeViewModel));
     }
     catch (Exception ex)
     {
         return(RedirectToAction("Index", "Error", new { message = ex.Message, stackTrace = ex.StackTrace }));
     }
 }