示例#1
0
        //<inheritdoc>
        public async Task AddUpdate(FoodSpecial foodSpec)
        {
            //Make web service
            await _restService.PostAsync(Constants.FoodSpecialsApiBaseUrl + "/Post", JsonConvert.SerializeObject(foodSpec));

            #region Update in local storage
            var restaurants = await RestaurantService.GetRestaurantsFromStorageAsync();

            foodSpec.Restaurant = restaurants.Single(x => x.Id == foodSpec.RestaurantId);
            var specs = await GetSpecsFromStorageAsync();

            if (foodSpec.SpecialId == 0)
            {
                specs.Add(foodSpec);
            }
            else
            {
                var old   = specs.First(x => x.SpecialId == foodSpec.SpecialId);
                var index = specs.IndexOf(old);

                if (index != -1)
                {
                    specs[index] = foodSpec;
                }
            }

            SetSpecsInStorage(specs);
            CrossSecureStorage.Current.SetValue(LSConstants.RefreshHome, "True");
            #endregion
        }
 public Task AddUpdate(FoodSpecial foodSpec)
 {
     Contract.Requires(foodSpec != null);
     throw new NotImplementedException();
 }