Exemplo n.º 1
0
        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");
        }
Exemplo n.º 2
0
        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");
        }
Exemplo n.º 3
0
 /// <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);
 }
Exemplo n.º 4
0
 /// <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);
 }
Exemplo n.º 5
0
        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");
        }
Exemplo n.º 6
0
 public ActionResult AddReference(Spell spell)
 {
     return View(spell);
 }