Пример #1
0
        public static async Task <User> GetByEmail(string email)
        {
            var data = await DataFeed.GetStringAsync("/Users?$filter=Email eq '" + email + "'");

            var user =
                from entry in XDocument.Parse(data).Descendants(DataFeed.xa + "entry").Descendants(DataFeed.xa + "content")
                let properties = entry.Element(DataFeed.xm + "properties")
                                 select new User
            {
                Address    = properties.Element(DataFeed.xd + "Address").Value,
                ScreenName = properties.Element(DataFeed.xd + "ScreenName").Value,
                Email      = properties.Element(DataFeed.xd + "Email").Value
            };

            try
            {
                var u = user.FirstOrDefault();

                return(u);
            }
            catch (Exception e)
            {
            }

            return(null);
        }
Пример #2
0
        public static async Task <bool> LoginUser(string email, string password)
        {
            var data = await DataFeed.GetStringAsync("/Users?$filter=Email eq '" + email + "'&password='******'");

            var user =
                from entry in XDocument.Parse(data).Descendants(DataFeed.xa + "entry").Descendants(DataFeed.xa + "content")
                let properties = entry.Element(DataFeed.xm + "properties")
                                 select new
            {
                Email = properties.Element(DataFeed.xd + "Email").Value
            };

            try
            {
                var u = user.FirstOrDefault();

                if (u == null)
                {
                    return(false);
                }
            }
            catch (Exception e)
            {
            }

            return(true);
        }
Пример #3
0
        public static async Task <bool> CreateUser(User user)
        {
            var data = await DataFeed.GetStringAsync("CreateUser?email='" + user.Email + "'&name='" + user.ScreenName + "'&address='" + user.Address + "'&password='******'");

            var success = XDocument.Parse(data).Root.Value;

            return(Convert.ToBoolean(success));
        }
Пример #4
0
        public static async Task <Deal[]> GetDealsAsync(string categoryId)
        {
            var data = await DataFeed.GetStringAsync(allDealsQuery);

            var deals =
                from entry in XDocument.Parse(data).Descendants(DataFeed.xa + "entry").Descendants(DataFeed.xa + "content")
                let properties = entry.Element(DataFeed.xm + "properties")
                                 where (properties.Element(DataFeed.xd + "CategoryRowKey").Value == categoryId) && (Convert.ToBoolean(properties.Element(DataFeed.xd + "Active").Value) == true)
                                 select properties;

            return(await PopulateDeals(deals));
        }
Пример #5
0
        public static async Task <Deal> GetDealAsync(string dealId)
        {
            var data = await DataFeed.GetStringAsync("Deals?$filter=RowKey eq '" + dealId + "'");

            var deals =
                from entry in XDocument.Parse(data).Descendants(DataFeed.xa + "entry").Descendants(DataFeed.xa + "content")
                let properties = entry.Element(DataFeed.xm + "properties")
                                 where (properties.Element(DataFeed.xd + "RowKey").Value == dealId) && (Convert.ToBoolean(properties.Element(DataFeed.xd + "Active").Value) == true)
                                 select properties;

            return(await PopulateDeal(deals.First()));
        }
Пример #6
0
        public static async Task <int> GetDealCount(string categoryId)
        {
            var data = await DataFeed.GetStringAsync("Deals?$filter=CategoryRowKey eq '" + categoryId + "'");

            var deals =
                (from entry in XDocument.Parse(data).Descendants(DataFeed.xa + "entry").Descendants(DataFeed.xa + "content")
                 let properties = entry.Element(DataFeed.xm + "properties")
                                  where (properties.Element(DataFeed.xd + "CategoryRowKey").Value == categoryId) &&
                                  (Convert.ToBoolean(properties.Element(DataFeed.xd + "Active").Value) == true)
                                  select entry).Count();

            return(deals);
        }
Пример #7
0
        public static async Task <Order> CheckOrder(string orderId)
        {
            var data = await DataFeed.GetStringAsync("/Orders?$filter=RowKey eq '" + orderId + "'");

            var order =
                from entry in XDocument.Parse(data).Descendants(DataFeed.xa + "entry").Descendants(DataFeed.xa + "content")
                let properties = entry.Element(DataFeed.xm + "properties")
                                 select new Order
            {
                Handled = (bool)properties.Element(DataFeed.xd + "Handled")
            };

            return(order.First());
        }
Пример #8
0
        public static async Task <Country> GetCountryAsync(string countryId)
        {
            var data = await DataFeed.GetStringAsync("Countries?$filter=RowKey eq '" + countryId + "'");

            var countries =
                from entry in XDocument.Parse(data).Descendants(DataFeed.xa + "entry").Descendants(DataFeed.xa + "content")
                let properties = entry.Element(DataFeed.xm + "properties")
                                 select new Country
            {
                CountryId             = (string)properties.Element(DataFeed.xd + "RowKey"),
                CountryName           = (string)properties.Element(DataFeed.xd + "CountryName"),
                CountryFlag250x250Url = (string)properties.Element(DataFeed.xd + "CountryFlag250x250Url")
            };

            return(countries.First());
        }
Пример #9
0
        public static async Task <Country[]> GetCountriesAsync()
        {
            var data = await DataFeed.GetStringAsync(allCountriesQuery);

            var countries =
                from entry in XDocument.Parse(data).Descendants(DataFeed.xa + "entry").Descendants(DataFeed.xa + "content")
                let properties = entry.Element(DataFeed.xm + "properties")
                                 select new Country
            {
                CountryId             = (string)properties.Element(DataFeed.xd + "RowKey"),
                CountryName           = (string)properties.Element(DataFeed.xd + "CountryName"),
                CountryFlag250x250Url = (string)properties.Element(DataFeed.xd + "CountryFlag250x250Url")
            };

            return(countries.ToArray());
        }
Пример #10
0
        public static async Task <Category[]> GetCategoriesAsync()
        {
            var data = await DataFeed.GetStringAsync(allCategoriesQuery);

            var categories =
                from entry in XDocument.Parse(data).Descendants(DataFeed.xa + "entry").Descendants(DataFeed.xa + "content")
                let properties = entry.Element(DataFeed.xm + "properties")
                                 select new Category
            {
                CategoryId   = (string)properties.Element(DataFeed.xd + "RowKey"),
                Name         = (string)properties.Element(DataFeed.xd + "Name"),
                LatestDealId = (string)properties.Element(DataFeed.xd + "LastestDealRowKey"),
                ImageUrl     = (string)properties.Element(DataFeed.xd + "ImageUrl"),
                DealCount    = (int)properties.Element(DataFeed.xd + "DealCount")
            };

            return(categories.ToArray());
        }
Пример #11
0
        public static async Task <Category> GetCategoryAsync(string categoryId)
        {
            var data = await DataFeed.GetStringAsync("Categories?$filter=RowKey eq '" + categoryId + "'");

            var categories =
                from entry in XDocument.Parse(data).Descendants(DataFeed.xa + "entry").Descendants(DataFeed.xa + "content")
                let properties = entry.Element(DataFeed.xm + "properties")
                                 select new Category
            {
                CategoryId   = (string)properties.Element(DataFeed.xd + "RowKey"),
                Name         = (string)properties.Element(DataFeed.xd + "Name"),
                LatestDealId = (string)properties.Element(DataFeed.xd + "LastestDealRowKey"),
                ImageUrl     = (string)properties.Element(DataFeed.xd + "ImageUrl"),
                DealCount    = (int)properties.Element(DataFeed.xd + "DealCount")
            };

            return(categories.First());
        }
Пример #12
0
        public static async Task <DealImage[]> GetDealImagesAsync(string dealId, string size)
        {
            if (string.IsNullOrEmpty(size))
            {
                size = "original";
            }

            var data = await DataFeed.GetStringAsync("DealImages?$filter=(DealRowKey eq '" + dealId + "') and (Handled eq true) and (ImageSize eq '" + size + "')");

            var dealImages =
                from entry in XDocument.Parse(data).Descendants(DataFeed.xa + "entry").Descendants(DataFeed.xa + "content")
                let properties = entry.Element(DataFeed.xm + "properties")
                                 select new DealImage
            {
                Name     = (string)properties.Element(DataFeed.xd + "Name"),
                ImageUrl = (string)properties.Element(DataFeed.xd + "ImageUrl")
            };

            return(dealImages.ToArray());
        }
Пример #13
0
        public static async Task <Deal[]> GetDealByWineTypeAsync(bool redWine)
        {
            var data = string.Empty;

            if (redWine)
            {
                data = await DataFeed.GetStringAsync("Deals?$filter=Redwine eq true");
            }
            else
            {
                data = await DataFeed.GetStringAsync("Deals?$filter=WhiteWine eq false");
            }

            var deals =
                from entry in XDocument.Parse(data).Descendants(DataFeed.xa + "entry").Descendants(DataFeed.xa + "content")
                let properties = entry.Element(DataFeed.xm + "properties")
                                 where (Convert.ToBoolean(properties.Element(DataFeed.xd + "Active").Value) == true)
                                 select properties;

            var list = await PopulateDeals(deals);

            return(list.Take(20).ToArray());
        }
Пример #14
0
 public static async void InitOrder(string orderId, string userId)
 {
     var data = await DataFeed.GetStringAsync(method + "?orderId='" + orderId + "'&userId='" + userId + "'");
 }