public IAsyncResult BeginGetRestaurantByName(string name, AsyncCallback callback, object asyncState) { var rootElement = XMLDataAccess.GetXMLRootElement <Restaurants>(); var result = rootElement.Restaurant.Select(resto => new RestaurantInfo(resto)).Single(resto => resto.Name == name); return(new CompletedAsyncResult <RestaurantInfo>(result)); }
public IAsyncResult BeginGetRestaurantsByRating(int rating, AsyncCallback callback, object asyncState) { var rootElement = XMLDataAccess.GetXMLRootElement <Restaurants>(); var result = rootElement.Restaurant.Select(resto => new RestaurantInfo(resto)).Where(resto => resto.Rating >= rating); return(new CompletedAsyncResult <IEnumerable <RestaurantInfo> >(result)); }
public IAsyncResult BeginGetRestaurantNames(AsyncCallback callback, object asyncState) { var rootElement = XMLDataAccess.GetXMLRootElement <Restaurants>(); var result = rootElement.Restaurant.Select(resto => resto.Name); return(new CompletedAsyncResult <IEnumerable <string> >(result)); }
public IAsyncResult BeginSaveRestaurant(RestaurantInfo restaurant, AsyncCallback callback, object asyncState) { var rootElement = XMLDataAccess.GetXMLRootElement <Restaurants>(); var restaurantToModify = rootElement.Restaurant.Single(resto => resto.Name == restaurant.Name); restaurantToModify.Summary = restaurant.Summary; restaurantToModify.Rating = restaurant.Rating; restaurantToModify.RestaurantAddress = new AddressType() { Address = restaurant.Location.Street, City = restaurant.Location.City, Province = Utility.Utility.StringToProvinceType[restaurant.Location.Province], PostalCode = restaurant.Location.PostalCode }; var result = XMLDataAccess.SaveToXML(rootElement); return(new CompletedAsyncResult <bool>(result)); }