コード例 #1
0
        public ContextResult <Service.CRM_Person> GetUserDetails(string key, string email, string password)
        {
            ServiceDataContext db = new ServiceDataContext();

            email = email.ToLower();

            var person = db.CRM_Persons.ToList().FirstOrDefault(c => !c.IsArchived && c.PrimaryEmail.ToLower() == email && c.Password == password);

            var tempPerson = new Service.CRM_Person()
            {
                PrimaryEmail     = person.PrimaryEmail,
                Title            = person.Title,
                Firstname        = person.Firstname,
                Lastname         = person.Lastname,
                PrimaryAddressID = person.PrimaryAddressID,
            };

            ContextResult <Service.CRM_Person> result = new ContextResult <Service.CRM_Person>()
            {
                ReturnObject = tempPerson
            };

            result.IsSuccess = IsAuthValid(key);

            SetResponseHeaders(result.IsSuccess);

            return(result);
        }
コード例 #2
0
        public ContextResult <List <string> > ActiveFriendEmails(string authKey)
        {
            bool valid = IsAuthValid(authKey);

            List <string> ActiveFriends = new List <string>();

            if (valid)
            {
                var now = UKTime.Now;

                using (ServiceDataContext db = new ServiceDataContext())
                {
                    foreach (Service.CRM_AnnualPass pass in db.CRM_AnnualPasses.Where(r => r.StartDate <= now && r.ExpiryDate >= now))
                    {
                        Service.CRM_Person person = db.CRM_Persons.FirstOrDefault(f => f.Reference == pass.PrimaryContactReference);

                        if (person != null && person.PrimaryEmail != "")
                        {
                            ActiveFriends.Add(person.PrimaryEmail.ToLower().Trim());
                        }
                    }
                }
            }

            ContextResult <List <string> > result = new ContextResult <List <string> >()
            {
                ReturnObject = ActiveFriends
            };

            result.IsSuccess = valid;

            SetResponseHeaders(result.IsSuccess);

            return(result);
        }
コード例 #3
0
        public ContextResult <Service.CRM_Person> GetPersonRecord(string authkey, int WebsiteAccountID)
        {
            ServiceDataContext db = new ServiceDataContext();

            Service.CRM_Person personAccount = db.CRM_Persons.FirstOrDefault(s => s.WebsiteAccountID == WebsiteAccountID);

            ContextResult <Service.CRM_Person> result = new ContextResult <Service.CRM_Person>()
            {
                ReturnObject = personAccount
            };

            result.IsSuccess = IsAuthValid(authkey);

            SetResponseHeaders(result.IsSuccess);

            return(result);
        }
コード例 #4
0
        public ContextResult <InterestAnswer[]> GetCurrentInterests(string authkey, int WebsiteAccountID)
        {
            ServiceDataContext db = new ServiceDataContext();

            Service.CRM_Person personAccount = db.CRM_Persons.FirstOrDefault(s => s.WebsiteAccountID == WebsiteAccountID);

            InterestAnswer[] items = (from a in db.CRM_FormFieldAnswers
                                      where a.CRM_FormFieldID == 24 && a.TargetReference == personAccount.Reference
                                      select new InterestAnswer {
                FormFieldID = a.CRM_FormFieldID, OptIn = a.Answer == "Yes"
            }).ToArray();

            ContextResult <InterestAnswer[]> result = new ContextResult <InterestAnswer[]>()
            {
                ReturnObject = items
            };

            result.IsSuccess = IsAuthValid(authkey);

            SetResponseHeaders(result.IsSuccess);

            return(result);
        }