public ActionResult AddReference(Spell spell, Reference reference)
        {
            // Check if the user is logged in
            if (Request.IsAuthenticated)
            {
                // Validate reference
                if (true)
                {
                    // Add reference to spell
                    spell.BookReferences.Add(reference);

                    // Update spell in database
                    _spellService.UpdateSpell(spell);

                    // Send the user back to the details page to see their update
                    return RedirectToAction("Details", spell.Id);
                }
                else
                {
                    // If the reference is not valid,
                    // report it to the user
                    return View();
                }
            }

            return RedirectToAction("Index");
        }
        public ActionResult Create()
        {
            if (Request.IsAuthenticated)
            {
                var someSpell = new Spell();
                someSpell.SpellLevels = new List<SpellLevel>
                {
                    new SpellLevel { SpellClass = "Wizard", Level = 1}
                };
                someSpell.Range = SpellRange.Self;
                return View(someSpell);
            }

            return RedirectToAction("Index");
        }
 /// <summary>
 /// Updates a spell in the database
 /// </summary>
 /// <param name="newSpell">Details for the spell</param>
 /// <returns>The new spell object</returns>
 public Spell UpdateSpell(Spell newSpell)
 {
     return _genericRepository.Update(newSpell);
 }
 /// <summary>
 /// Add a spell to the database
 /// </summary>
 /// <param name="newSpell">Details for the new spell</param>
 public void CreateSpell(Spell newSpell)
 {
     _genericRepository.Create(newSpell);
 }
        public ActionResult Create(Spell value)
        {
            // Check if the user is logged in
            if (Request.IsAuthenticated)
            {
                // Clean up the spell input
                foreach (var someClass in value.SpellLevels)
                {
                    someClass.SpellClass = someClass.SpellClass.TrimEnd(" ".ToCharArray());
                    someClass.SpellClass = someClass.SpellClass.TrimStart(" ".ToCharArray());
                }

                // Enter in the user data who created the spell
                value.Editor = User.Identity.Name;
                value.LastEdited = DateTime.Now;

                // Add the spell to the database
                _spellService.CreateSpell(value);
            }

            return RedirectToAction("Index");
        }
 public ActionResult AddReference(Spell spell)
 {
     return View(spell);
 }