Ejemplo n.º 1
0
        public static async Task <LeadDM> LoadByMsisdnOrEmailAsync(DirectDatabaseBase db, string msisdn, string email)
        {
            if (string.IsNullOrEmpty(msisdn) && string.IsNullOrEmpty(email))
            {
                return(null);
            }

            LeadDM result = null;

            if (!string.IsNullOrEmpty(msisdn) && !string.IsNullOrEmpty(email))
            {
                result = (await db.Query <LeadDM>().Select("email, msisdn").Where("msisdn={0} AND email={1}", msisdn, email).LoadAsync()).FirstOrDefault();
            }

            if (result == null && !string.IsNullOrEmpty(msisdn))
            {
                result = (await db.Query <LeadDM>().Select("email, msisdn").Where("msisdn={0}", msisdn).LoadAsync()).FirstOrDefault();
            }

            if (result == null && !string.IsNullOrEmpty(email))
            {
                result = (await db.Query <LeadDM>().Select("email, msisdn").Where("email={0}", email).LoadAsync()).FirstOrDefault();
            }

            return(result);
        }
Ejemplo n.º 2
0
        public static async Task <LeadDM> LoadAndInsertByMsisdnOrEmailAsync(DirectDatabaseBase db, string msisdn, string email)
        {
            var result = await LoadByMsisdnOrEmailAsync(db, msisdn, email);

            if (result != null)
            {
                return(result);
            }

            result = new LeadDM(db)
            {
                msisdn = msisdn,
                email  = email
            };
            await result.InsertAsync();

            return(result);
        }