Esempio n. 1
0
        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));
        }
Esempio n. 2
0
        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));
        }
Esempio n. 3
0
        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));
        }
Esempio n. 4
0
        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));
        }