public IHttpActionResult Put(int id, [FromBody] ModelsShared.Models.customer value)
 {
     try
     {
         return(Ok(context.Put(id, value)));
     }
     catch (Exception ex)
     {
         return(Content(HttpStatusCode.NotModified, ex.Message));
     }
 }
Esempio n. 2
0
        //private async void RegisterAsyncHandler(HttpResponseMessage response)
        //{
        //    if (response.IsSuccessStatusCode)
        //    {
        //        var result = await response.Content.ReadAsAsync<customer>();
        //        if (result != null)
        //        {
        //            var MainVM = Common.ResourcesBase.GetMainWindowViewModel();
        //            await MainVM.MessageCollection.Add(new Message { MessageText = string.Format("{0} Is Registered", result.Name) });
        //        }
        //    }
        //}

        private async void EditAction()
        {
            var vm  = new Customer.CustomerEditVM(Collection.SelectedItem);
            var cnt = new Customer.Edit();

            cnt.DataContext = vm;
            var dlg = new ModernDialog
            {
                Title   = "Edit Customer",
                Content = cnt
            };

            dlg.Buttons = new Button[] { dlg.OkButton, dlg.CancelButton };
            dlg.ShowDialog();


            if (dlg.MessageBoxResult == System.Windows.MessageBoxResult.OK)
            {
                var newitem = new ModelsShared.Models.customer
                {
                    Address      = vm.Address,
                    ContactName  = vm.ContactName,
                    CustomerType = vm.CustomerType,
                    Email        = vm.Email,
                    Handphone    = vm.Handphone,
                    Id           = vm.Id,
                    Name         = vm.Name,
                    Phone1       = vm.Phone1,
                    Phone2       = vm.Phone2,
                    CityID       = vm.CityID
                };
                var isUpdate = await Collection.Update(Collection.SelectedItem.Id, newitem);

                if (isUpdate)
                {
                    Collection.SourceView.Refresh();
                    ModernDialog.ShowMessage("Data Is Updated !", "Message Dialog", System.Windows.MessageBoxButton.OK);
                }
            }
        }