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); }
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); }
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)); }
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)); }
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())); }
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); }
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()); }
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()); }
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()); }
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()); }
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()); }
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()); }
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()); }
public static async void InitOrder(string orderId, string userId) { var data = await DataFeed.GetStringAsync(method + "?orderId='" + orderId + "'&userId='" + userId + "'"); }