public virtual ActionResult Edit(string id, AwardEditModel a) { var x = Awards.Get(id); if (!ModelState.IsValid) { return(View(a)); } try { a.Apply(x, Accounting); Awards.Save(x); return(this.RedirectToAction(c => c.Index())); } catch (Exception ex) { ViewData["groups"] = GroupSummaries; ViewData["users"] = UserSummaries[ (a.Availability.Users ?? new string[0]).Union( a.NomineeUsers ?? new string[0]) ]; Notifier.Notify(ex); return(View(x)); } }
public override void Use(Player p, string message) { if (message == "" || message.IndexOf(' ') == -1) { Help(p); return; } bool take = false; if (message.CaselessStarts("give ")) { message = message.Substring(5); } else if (message.CaselessStarts("take ")) { message = message.Substring(5); take = true; } string[] args = message.Split(trimChars, 2); string plName = args[0]; Player who = PlayerInfo.Find(plName); if (who != null) { plName = who.name; } string award = args.Length > 1 ? args[1] : ""; award = Awards.Find(award); if (award == null) { Player.SendMessage(p, "The award you entered doesn't exist"); Player.SendMessage(p, "Use /awards for a list of awards"); return; } if (!take) { if (Awards.GiveAward(plName, award)) { Player.GlobalMessage(Server.FindColor(plName) + plName + " %Swas awarded: &b" + award); } else { Player.SendMessage(p, "The player already has that award."); return; } } else { if (Awards.TakeAward(plName, award)) { Player.GlobalMessage(Server.FindColor(plName) + plName + " %Shad their &b" + award + " %Saward removed"); } else { Player.SendMessage(p, "The player didn't have the award you tried to take"); return; } } Awards.Save(); }
public override void Use(Player p, string message) { if (message == "" || message.IndexOf(' ') == -1) { Help(p); return; } string foundPlayer = message.Split(' ')[0]; Player who = Player.Find(message); if (who != null) { foundPlayer = who.name; } string awardName = message.Substring(message.IndexOf(' ') + 1); if (!Awards.awardExists(awardName)) { Player.SendMessage(p, "The award you entered doesn't exist"); Player.SendMessage(p, "Use /awards for a list of awards"); return; } if (Awards.giveAward(foundPlayer, awardName)) { Player.GlobalChat(p, Server.FindColor(foundPlayer) + foundPlayer + Server.DefaultColor + " was awarded: &b" + Awards.camelCase(awardName), false); } else { Player.SendMessage(p, "The player already has that award!"); } Awards.Save(); }
public override void Use(Player p, string message) { if (message == "" || message.IndexOf(' ') == -1) { Help(p); return; } bool add = true; if (message.Split(' ')[0].ToLower() == "add") { message = message.Substring(message.IndexOf(' ') + 1); } else if (message.Split(' ')[0].ToLower() == "del") { add = false; message = message.Substring(message.IndexOf(' ') + 1); } if (add) { if (message.IndexOf(":") == -1) { Player.SendMessage(p, "&cMissing a colon!"); Help(p); return; } string awardName = message.Split(':')[0].Trim(); string description = message.Split(':')[1].Trim(); if (!Awards.addAward(awardName, description)) { Player.SendMessage(p, "This award already exists!"); } else { Player.GlobalMessage("Award added: &6" + awardName + " : " + description); } } else { if (!Awards.removeAward(message)) { Player.SendMessage(p, "This award doesn't exist!"); //corrected spelling error } else { Player.GlobalMessage("Award removed: &6" + message); } } Awards.Save(); }
public override void Use(Player p, string message) { if (message == "" || message.IndexOf(' ') == -1) { Help(p); return; } string[] args = message.Split(trimChars, 3); string plName = args[args.Length - 2]; Player who = PlayerInfo.Find(plName); if (who != null) { plName = who.name; } string award = args[args.Length - 1]; if (!Awards.ExistsAward(award)) { Player.SendMessage(p, "The award you entered doesn't exist"); Player.SendMessage(p, "Use /awards for a list of awards"); return; } if (args.Length == 2 || !args[0].CaselessEq("take")) { if (Awards.GiveAward(plName, award)) { Player.GlobalMessage(Server.FindColor(plName) + plName + " %Swas awarded: &b" + award); } else { Player.SendMessage(p, "The player already has that award."); return; } } else { if (Awards.TakeAward(plName, award)) { Player.GlobalMessage(Server.FindColor(plName) + plName + " %Shad their &b" + award + " %Saward removed"); } else { Player.SendMessage(p, "The player didn't have the award you tried to take"); return; } } Awards.Save(); }
public override void Use(Player p, string message) { if (message == "" || message.IndexOf(' ') == -1) { Help(p); return; } string[] args = message.Split(trimChars, 2); if (!(args[0].CaselessEq("add") || args[0].CaselessEq("del"))) { Help(p); return; } if (args[0].CaselessEq("add")) { args = args[1].Split(awardArgs, 2); if (args.Length == 1) { Player.SendMessage(p, "&cUse a : to separate the award name from its description."); Help(p); return; } if (!Awards.Add(args[0], args[1])) { Player.SendMessage(p, "This award already exists."); return; } else { Player.GlobalMessage("Award added: &6" + args[0] + " : " + args[1]); } } else { if (!Awards.Remove(args[1])) { Player.SendMessage(p, "This award does not exist."); return; } else { Player.GlobalMessage("Award removed: &6" + args[1]); } } Awards.Save(); }
public virtual ActionResult Index(AwardCreateModel a) { ViewData["a"] = a; if (!ModelState.IsValid) { return(View(Awards.All().WithDocuments())); } var x = a.CreateAward(); try { Awards.Save(x); return(this.RedirectToAction(c => c.Edit(x.Document.Id))); } catch (Exception ex) { Notifier.Notify(ex); return(View(Awards.All().WithDocuments())); } }
public override void Use(Player p, string message) { if (message == "" || message.IndexOf(' ') == -1) { Help(p); return; } bool give = true; if (message.Split(' ')[0].ToLower() == "give") { give = true; message = message.Substring(message.IndexOf(' ') + 1); } else if (message.Split(' ')[0].ToLower() == "take") { give = false; message = message.Substring(message.IndexOf(' ') + 1); } string foundPlayer = message.Split(' ')[0]; Player who = Player.Find(message); if (who != null) { foundPlayer = who.name; } string awardName = message.Substring(message.IndexOf(' ') + 1); if (!Awards.awardExists(awardName)) { Player.SendMessage(p, "The award you entered doesn't exist"); Player.SendMessage(p, "Use /awards for a list of awards"); return; } if (give) { if (Awards.giveAward(foundPlayer, awardName)) { Player.GlobalMessage(Server.FindColor(foundPlayer) + foundPlayer + Server.DefaultColor + " was awarded: &b" + Awards.camelCase(awardName)); } else { Player.SendMessage(p, "The player already has that award!"); } } else { if (Awards.takeAward(foundPlayer, awardName)) { Player.GlobalMessage(Server.FindColor(foundPlayer) + foundPlayer + Server.DefaultColor + " had their &b" + Awards.camelCase(awardName) + Server.DefaultColor + " award removed"); } else { Player.SendMessage(p, "The player didn't have the award you tried to take"); } } Awards.Save(); }