Exemplo n.º 1
0
        public Edit(string restID)
        {
            // Constructor.
            IModel model = (DataBaseModel)Application.Current.Properties["model"];

            DataContext = new ViewModelEdit(model);

            var VMIsEdit      = "VM_IsEdit";
            var bindingIsEdit = new Binding(VMIsEdit)
            {
                Mode = BindingMode.TwoWay
            };

            this.SetBinding(IsEditProperty, bindingIsEdit);

            IsEdit = true;

            var VMUpdateRest      = "VM_RestDetails";
            var bindingUpdateRest = new Binding(VMUpdateRest)
            {
                Mode = BindingMode.TwoWay
            };

            this.SetBinding(UpdateRestProperty, bindingUpdateRest);

            InitializeComponent();

            // Initialize the fileds.
            idRest = restID;
            city   = "";
            price  = "";
            flagFromPriceSelected = false;
        }
Exemplo n.º 2
0
        public EditOpeList()
        {
            this.InitializeComponent();
            vmEdit = new ViewModelEdit();

            this.DataContext = vmEdit;
        }
Exemplo n.º 3
0
        protected ActionResult ViewEditOr404 <T>(T modelObject)
            where T : ModelEditBase
        {
            var viewModel = new ViewModelEdit <T>
            {
                ModelObject = modelObject
            };

            return(ViewOr404(viewModel, () => View(viewModel)));
        }
Exemplo n.º 4
0
        protected ActionResult ViewEditOr404 <T>(T modelObject, Func <ActionResult> renderView)
            where T : ModelEditBase
        {
            var viewModel = new ViewModelEdit <T>
            {
                ModelObject = modelObject
            };

            return(ViewOr404(viewModel, renderView));
        }
Exemplo n.º 5
0
 protected ActionResult SaveOr404 <T>(ViewModelEdit <T> viewModel, bool forceUpdate = false, Func <ActionResult> sucessCallback = null)
     where T : ModelEditBase
 {
     return(ViewOr404(viewModel, () =>
     {
         if (SaveObject(viewModel.ModelObject, forceUpdate))
         {
             return sucessCallback == null ? RedirectToAction("Index") : sucessCallback();
         }
         return View(viewModel);
     }));
 }
Exemplo n.º 6
0
 protected ActionResult DeleteOr404 <T>(int id, ViewModelEdit <T> viewModel)
     where T : ModelEditBase
 {
     if (!viewModel.Found)
     {
         return(NotFound());
     }
     if (DeleteObject(viewModel.ModelObject))
     {
         return(RedirectToAction("Index"));
     }
     return(RedirectToAction("Delete", new { id, saveChangesError = true }));
 }
Exemplo n.º 7
0
        protected ActionResult ViewDeleteOr404 <T>(int?id, T modelObject)
            where T : ModelEditBase
        {
            if (!id.HasValue)
            {
                return(BadRequest());
            }
            var viewModel = new ViewModelEdit <T>
            {
                ModelObject = modelObject
            };

            return(ViewDeleteOr404(viewModel));
        }
Exemplo n.º 8
0
 private void Control_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
 {
     viewModel = e.NewValue as ViewModelEdit;
 }