/// <summary>
        /// Gets the username of the oldest linked account to the username passed.
        /// </summary>
        /// <param name="db"></param>
        /// <param name="username"></param>
        /// <returns></returns>
        public static string GetOldestLinkedAcccountUsername(CSSDataContext db, string username)
        {
            var alias = Alias.GetAliasByCallsign(db, username);

            var oldestLogin = alias.Login.Identity.Logins.OrderBy(p => p.DateCreated).FirstOrDefault(p => p != alias.Login);

            return(oldestLogin.Username);
        }
        /// <summary>
        /// Returns true if the username is linked to another account, and the username is not the oldest account.
        /// </summary>
        /// <param name="db"></param>
        /// <param name="username"></param>
        /// <returns></returns>
        public static bool IsLinkedToAnOlderAccount(CSSDataContext db, string username)
        {
            var alias = Alias.GetAliasByCallsign(db, username);

            if (alias != null)
            {
                if (alias.Login.Identity.Logins.Count > 1)
                {
                    if (alias.Login != alias.Login.Identity.Logins.OrderBy(p => p.DateCreated).FirstOrDefault())
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
Esempio n. 3
0
        static public List <IMessage> GetGlobalMessages(CSSDataContext db, string callsign)
        {
            var   messages = new List <IMessage>();
            Alias alias    = Alias.GetAliasByCallsign(db, callsign);

            messages.AddRange(
                db.GroupMessages
                .Where(p => p.DateCreated > alias.Login.Identity.LastGlobalMessageDelivery &&
                       p.DateToSend.Date <= DateTime.Now.Date &&
                       p.DateExpires > DateTime.Now.Date &&
                       p.GroupId == null)
                .Select(q => (IMessage)q).ToList()
                );

            alias.Login.Identity.LastGlobalMessageDelivery = DateTime.Now;

            db.SubmitChanges();

            return(messages);
        }