コード例 #1
0
        private bool ValidateRestaurant(ModelLibrary.Restaurant restaurant)
        {
            var context = new ValidationContext(restaurant, null, null);
            var result  = new List <System.ComponentModel.DataAnnotations.ValidationResult>();

            return(Validator.TryValidateObject(restaurant, context, result, true));
        }
コード例 #2
0
        private void button_Click(object sender, RoutedEventArgs e)
        {
            var proxyRestaurant = new RestaurantServiceClient();
            var res             = proxyRestaurant.GetRestaurant(resId);
            var modelRes        = new ModelLibrary.Restaurant
            {
                Name         = textBoxName.Text,
                Address      = textBoxAddress.Text,
                Email        = textBoxEmail.Text,
                ZipCode      = textBoxZipCode.Text,
                Category     = res.Category,
                PhoneNo      = textBoxPhone.Text,
                Verified     = res.Verified,
                Discontinued = res.Discontinued,
                Id           = resId
            };
            var validation = ValidateRestaurant(modelRes);

            if (validation == true)
            {
                proxyRestaurant.UpdateRestaurant(modelRes);
            }
            else
            {
                MessageBox.Show("Validation did not pass");
            }
        }
コード例 #3
0
        public RestaurantUpdate(int restaurantId)
        {
            InitializeComponent();
            resId = restaurantId;
            var proxyRestaurant = new RestaurantServiceClient();

            ModelLibrary.Restaurant res = proxyRestaurant.GetRestaurant(resId);
            comboBoxCategory.ItemsSource   = proxyRestaurant.GetAllRestaurantCategories();
            comboBoxCategory.SelectedIndex = 0;
            if (res != null)
            {
                textBoxName.Text               = res.Name;
                textBoxAddress.Text            = res.Address;
                textBoxZipCode.Text            = res.ZipCode;
                textBoxPhone.Text              = res.PhoneNo;
                textBoxEmail.Text              = res.Email;
                textBoxcategory.Text           = res.Category.ToString();
                checkBoxDiscontinued.IsChecked = res.Discontinued;
                checkBoxVerified.IsChecked     = res.Verified;
            }
            else
            {
                textBoxName.Text               = "";
                textBoxAddress.Text            = "";
                textBoxZipCode.Text            = "";
                textBoxPhone.Text              = "";
                textBoxEmail.Text              = "";
                textBoxcategory.Text           = "";
                checkBoxDiscontinued.IsChecked = false;
                checkBoxVerified.IsChecked     = false;
            }
        }
コード例 #4
0
 public System.Threading.Tasks.Task UpdateRestaurantAsync(ModelLibrary.Restaurant restaurant)
 {
     return(base.Channel.UpdateRestaurantAsync(restaurant));
 }
コード例 #5
0
 public void UpdateRestaurant(ModelLibrary.Restaurant restaurant)
 {
     base.Channel.UpdateRestaurant(restaurant);
 }