Exemplo n.º 1
0
        public ActionResult View(Guid Id)
        {
            CharacterService cs = new CharacterService(FILENAME, User.Identity.Name);
            CharacterModel cm = new CharacterModel();
            Character c = cs.GetCharacter(Id);
            cm.Name = c.Name;
            cm.Faction = c.Faction.ToString();
            cm.Race = c.Race.ToString();
            cm.Class = c.Class.ToString();
            cm.Level = c.Level;
            cm.Active = c.Active;

            PlayerService ps = new PlayerService(FILENAME);
            var p = ps.GetPlayer(User.Identity.Name);

            if (p.Characters.Exists(x => x.Faction == CharacterFaction.Horde && x.Active == true))
            {
                ViewBag.PlayerFaction = "Horde";
            }
            else if (p.Characters.Exists(x => x.Faction == CharacterFaction.Alliance && x.Active == true))
            {
                ViewBag.PlayerFaction = "Alliance";
            }

            if(p.Characters.Exists(x => x.Active && x.Level >= 55))
            {
                ViewBag.DeathKnightAvailable = true;
            }
            else
            {
                ViewBag.DeathKnightAvailable = false;
            }

            return View(cm);
        }
Exemplo n.º 2
0
        public ActionResult Create(CharacterAddModel model)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    CharacterService cs = new CharacterService(FILENAME, User.Identity.Name);
                    cs.AddCharacter(model.Name, model.Faction, model.Race, model.Class);
                    return RedirectToAction("Index", "Home");
                }
                catch (Exception e)
                {
                    ModelState.AddModelError("", e.Message);
                }
            }

            return View(model);
        }
Exemplo n.º 3
0
 public ActionResult CharacterEdit(Guid id, string userName)
 {
     // check access
     if (VerifyAccess())
     {
         return RedirectToAction("Index", "Home");
     }
     CharacterService cr = new CharacterService(FILENAME, userName);
     CharacterModel cm = new CharacterModel();
     Character c = cr.GetCharacter(id);
     cm.Name = c.Name;
     cm.Faction = c.Faction.ToString();
     cm.Race = c.Race.ToString();
     cm.Class = c.Class.ToString();
     cm.Level = c.Level;
     cm.Active = c.Active;
     return View(cm);
 }
Exemplo n.º 4
0
        public ActionResult ActiveToggle(Guid Id)
        {
            CharacterService cs = new CharacterService(FILENAME, User.Identity.Name);
            try
            {
                Character c = cs.GetCharacter(Id);
                cs.EditCharacter(c.Id, c.Name, c.Faction.ToString(), c.Race.ToString(), c.Class.ToString(), c.Level, !c.Active);
            }
            catch(Exception e)
            {
            }

            return RedirectToAction("Index", "Home");
        }
Exemplo n.º 5
0
        public ActionResult CharacterEdit(CharacterModel model, Guid id, string userName)
        {
            // check access
            if (VerifyAccess())
            {
                return RedirectToAction("Index", "Home");
            }
            if (ModelState.IsValid)
            {
                 try
                 {
                     CharacterService cs = new CharacterService(FILENAME, userName);
                     cs.EditCharacter(id, model.Name, model.Faction, model.Race, model.Class, model.Level, model.Active);
                     return RedirectToAction("PlayerEdit", "Admin", new { id = userName });
                 }
                 catch (Exception e)
                 {
                     ModelState.AddModelError("", e.Message);
                 }
            }

            return View(model);
        }