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); }
public ActionResult Index() { PlayerModel pm = new PlayerModel(); PlayerService ps = new PlayerService(FILENAME); pm.Player = ps.GetPlayer(User.Identity.Name); return View(pm); }
public ActionResult PlayerEdit(PlayerModel model, string id) { // check access if (VerifyAccess()) { return RedirectToAction("Index", "Home"); } if (ModelState.IsValid) { try { PlayerService ps = new PlayerService(FILENAME); ps.EditPlayer(id, model.Player.IsAdmin); if (User.Identity.Name.Equals(id, StringComparison.OrdinalIgnoreCase)) { Session["OverRideIsAdmin"] = model.Player.IsAdmin; } return RedirectToAction("View", "Admin"); } catch (Exception e) { ModelState.AddModelError("", e.Message); } } return View(model); }
public ActionResult View() { // check access if (VerifyAccess()) { return RedirectToAction("Index", "Home"); } PlayerService ps = new PlayerService(FILENAME); PlayersModel pm = new PlayersModel(); pm.Players = ps.GetPlayer(); return View(pm); }
public ActionResult PlayerEdit(string id) { // check access if (VerifyAccess()) { return RedirectToAction("Index", "Home"); } PlayerService ps = new PlayerService(FILENAME); PlayerModel pm = new PlayerModel(); Player p = ps.GetPlayer(id); pm.Player = p; return View(pm); }
public ActionResult Create() { 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"; } CharacterAddModel cm = new CharacterAddModel(); return View(cm); }
public ActionResult Login(LoginViewModel model) { if (ModelState.IsValid) { try { PlayerService ps = new PlayerService(FILENAME); Player p = ps.GetPlayer(model.UserName, model.Password); CustomPrincipalSerializeModel serializeModel = new CustomPrincipalSerializeModel(); serializeModel.IsAdmin = p.IsAdmin; JavaScriptSerializer serializer = new JavaScriptSerializer(); string userData = serializer.Serialize(serializeModel); FormsAuthenticationTicket authTicket = new FormsAuthenticationTicket( 1, model.UserName, DateTime.Now, DateTime.Now.AddHours(10), false, userData); string encTicket = FormsAuthentication.Encrypt(authTicket); HttpCookie faCookie = new HttpCookie(FormsAuthentication.FormsCookieName, encTicket); Response.Cookies.Add(faCookie); return RedirectToAction("Index", "Home"); } catch (Exception e) { ModelState.AddModelError("", e.Message); } } return View(model); }
public ActionResult Register(RegisterViewModel model) { if (ModelState.IsValid) { try { PlayerService ps = new PlayerService(FILENAME); ps.AddPlayer(model.UserName, model.Password); return Login(new LoginViewModel() { UserName = model.UserName, Password = model.Password }); } catch(Exception e) { ModelState.AddModelError("", e.Message); } } return View(model); }