Example #1
0
        public static async Task PersistApplicant(Applicant a)
        {
            ApplicantEntity entity = new ApplicantEntity();

            entity.Data   = a.ToString();
            entity.RowKey = a.Phone;
            await Table.CreateIfNotExistsAsync();

            TableOperation to = TableOperation.InsertOrReplace(entity);
            TableResult    r  = await Table.ExecuteAsync(to);
        }
Example #2
0
        public static async Task <Applicant> GetApplicantByEmail(string email)
        {
            await Table.CreateIfNotExistsAsync();

            // this is brute force retrieval and in memory filtering. Very bad, but ok for the purpose here. Unfortunately the
            // only option with table storage.
            // Construct the query operation for all customer entities where PartitionKey="Smith".
            TableQuery <ApplicantEntity> query = new TableQuery <ApplicantEntity>().
                                                 Where(TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, "X-Bot FirstClass"));

            ApplicantEntity entity = Table.ExecuteQuery(query).FirstOrDefault <ApplicantEntity>(a => Applicant.FromJsonString(a.Data).Email.ToLower() == email.ToLower());

            if (entity == null)
            {
                return(null);
            }
            else
            {
                return(Applicant.FromJsonString(entity.Data));
            }
        }