Example #1
0
        public void TestPeopleModel()
        {
            PCs.DeleteBy(Condition.Empty); // avoid FK error.
            List <PeopleModel> l = PeopleModel.Find(Condition.Empty);

            Assert.AreEqual(3, l.Count);
            Assert.AreEqual("Tom", l[0].Name);

            PeopleModel p = PeopleModel.FindByName("Jerry");

            Assert.AreEqual(2, p.Id);
            Assert.IsTrue(p.IsValid());

            p.Name = "llf";
            Assert.IsTrue(p.IsValid());
            p.Save();

            PeopleModel p1 = PeopleModel.FindById(2);

            Assert.AreEqual("llf", p1.Name);

            p.Delete();
            p1 = PeopleModel.FindById(2);
            Assert.IsNull(p1);

            p = new PeopleModel {
                Name = "123456"
            };
            Assert.IsFalse(p.IsValid());

            Assert.AreEqual(1, PeopleModel.CountName("Tom"));
            Assert.AreEqual(0, PeopleModel.CountName("xyz"));
        }
Example #2
0
        public PC GetPlayerCharacter(ulong serverID, ulong userID, string nameOrAlias)
        {
            try
            {
                if (nameOrAlias == "")
                {
                    return(GetDefaultCharacter(serverID, userID));
                }

                var user = Users.SingleOrDefault(x => x.DiscordID == (long)userID);
                // Does the user have privilegies?
                if (!user.Roles.Where(x => x.Server.DiscordID == (long)serverID).Any(x => x.Role.Name.Equals("GM") || x.Role.Name.Equals("Admin") || x.Role.Name.Equals("ServerOwner")))
                {
                    return(PCs.SingleOrDefault(x => x.Player.DiscordID == (long)userID &&
                                               x.Server.DiscordID == (long)serverID &&
                                               (x.Name.Equals(nameOrAlias) || x.Alias.Equals(nameOrAlias))));
                }
                else
                {
                    return(PCs.SingleOrDefault(x => x.Server.DiscordID == (long)serverID &&
                                               (x.Name.Equals(nameOrAlias) || x.Alias.Equals(nameOrAlias))));
                }
            } catch (Exception e)
            {
                Console.WriteLine($"Error retrieving character: {e.Message}\n{e.StackTrace}");
                throw;
            }
        }
Example #3
0
 public void DeleteCharacter(Character _character)
 {
     if (_character.IsPlayable == true && PCs.Contains(_character) == true)
     {
         PCs.Remove(_character);
     }
     else if (_character.IsPlayable == false && NPCs.Contains(_character) == true)
     {
         NPCs.Remove(_character);
     }
 }
Example #4
0
 /// <summary>
 /// [EDITOR ONLY]
 /// </summary>
 /// <param name="_character"></param>
 public void AddCharacter(Character _character)
 {
     if (_character.IsPlayable == true && PCs.Contains(_character) == false)
     {
         PCs.Add(_character);
     }
     else if (_character.IsPlayable == false && NPCs.Contains(_character) == false)
     {
         NPCs.Add(_character);
     }
 }
Example #5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!this.IsPostBack)
            {
                BLClient client = null;

                try
                {
                    client = new BLClient();

                    // logon conditions: if user is logged on, present their streams, else present the one stream they created
                    // unregistered.
                    if (Session["User"] == null && Session["PcProfileToken"] != null)
                    {
                        PCs.DataSource = client.GetSubscriptionsNotRegistered((string)Session["PcProfileToken"]);

                        client.RemoveTemporaryPCProfilesNotRegistered((string)Session["PcProfileToken"]);

                        Session.Remove("PcProfileToken");
                    }
                    else if (Session["User"] != null)
                    {
                        PCs.DataSource = client.GetSubscriptions(((User)Session["User"]).UserID);

                        client.RemoveTemporaryPCProfiles(((User)Session["User"]).UserID);
                    }
                    else
                    {
                        client.Dispose();
                        Response.Redirect("Download.aspx");
                    }

                    PCs.DataBind();
                }
                finally
                {
                    if (client != null)
                    {
                        client.Dispose();
                    }
                }
            }
        }