Exemple #1
0
 public static void RemoveServerCompanyMember(int companyId, int charId)
 {
     try
     {
         if (companyId == 0 || charId == 0)
         {
             return;
         }
         var companyMemberData = ServerCompanysMember_.FirstOrDefault(x => x.companyId == companyId && x.charId == charId);
         if (companyMemberData != null)
         {
             ServerCompanysMember_.Remove(companyMemberData);
             using (gtaContext db = new gtaContext())
             {
                 db.Server_Company_Members.Remove(companyMemberData);
                 db.SaveChanges();
             }
             CharactersTablet.ChangeCharacterTabletAppInstallState(charId, "company", false);
         }
     }
     catch (Exception e)
     {
         Alt.Log($"{e}");
     }
 }
Exemple #2
0
        public static void CreateServerCompanyMember(int companyId, int charId, int rank)
        {
            try
            {
                if (companyId == 0 || charId == 0)
                {
                    return;
                }
                var companyData = ServerCompanysData_.FirstOrDefault(x => x.id == companyId);
                if (companyData != null)
                {
                    var companyMemberList = ServerCompanysMember_.FirstOrDefault(x => x.charId == charId);
                    if (companyMemberList != null)
                    {
                        return;
                    }
                    var companyMemberData = new Server_Company_Members
                    {
                        companyId        = companyId,
                        charId           = charId,
                        rank             = rank,
                        invitedTimestamp = DateTime.Now
                    };

                    ServerCompanysMember_.Add(companyMemberData);
                    using (gtaContext db = new gtaContext())
                    {
                        db.Server_Company_Members.Add(companyMemberData);
                        db.SaveChanges();
                    }

                    CharactersTablet.ChangeCharacterTabletAppInstallState(charId, "company", true);
                }
            }
            catch (Exception e)
            {
                Alt.Log($"{e}");
            }
        }