/// <summary>
        /// Tryies to register a user with db table of User
        /// </summary>
        /// <param name="email"></param>
        /// <param name="password"></param>
        /// <param name="confirmPassword"></param>
        /// <returns></returns>
        public static async Task <bool> Register(string email, string password, string confirmPassword)
        {
            bool result = false;

            if (!string.IsNullOrEmpty(password))
            {
                if (password == confirmPassword)
                {
                    var deliveryPerson = new DeliveryPerson()
                    {
                        Email    = email,
                        Password = password,
                    };

                    //await AzureHelper.MobileService.GetTable<User>().InsertAsync(user);        // insert record to Azure db table

                    // Use AzureHelper's bespoke generic method instead to write (in this case a record to User table) 18-152
                    //AzureHelper.Insert<User>(ref user);     // actually type (User) inferred from object instance (user)
                    //AzureHelper.Insert(ref user); // ref not used
                    AzureHelper.Insert(deliveryPerson);           // type still inferred


                    result = true;
                }
            }
            return(result);
        }
Example #2
0
        public static async Task <DeliveryPerson> GetDeliveryPerson(string id)
        {
            DeliveryPerson person = new DeliveryPerson();

            person = (await AzureHelper.MobileService.GetTable <DeliveryPerson>().Where(d => d.Id == id).ToListAsync()).FirstOrDefault();

            return(person);
        }
        public static async Task <DeliveryPerson> GetDeliveryPerson(string id)
        {
            DeliveryPerson person = new DeliveryPerson();

            person = (await AzureHelper.MobileService.GetTable <DeliveryPerson>().Where(dp => dp.Id == id).ToListAsync()).FirstOrDefault();
            // NB pattern for single instances (eg an individual person) - brackets and ().FirstOrDefault

            return(person);
        }
        public static async Task <bool> Register(string email, string password, string confirmPassword)
        {
            bool result = false;

            if (!string.IsNullOrEmpty(password))
            {
                if (password == confirmPassword)
                {
                    var user = new DeliveryPerson()
                    {
                        Email    = email,
                        Password = password
                    };

                    await AzureHelper.Insert(user);

                    result = true;
                }
            }

            return(result);
        }