Example #1
0
        private void ShowView(CrudType action, Unidade target)
        {
            this._container.RegisterInstance <Unidade>(target);
            IUnitPresenter presenter = this._container.Resolve <IUnitPresenter>("IUnitPresenter");

            presenter.CloseViewRequested += delegate(object sender, EventArgs eventArgs)
            {
                if (eventArgs is CloseViewEventArgs)
                {
                    if ((eventArgs as CloseViewEventArgs).CloseViewOption == CloseViewType.Submit)
                    {
                        var repository = _container.Resolve <IUnitRepository>();

                        switch (action)
                        {
                        case CrudType.Create:
                            repository.Add(presenter.Unidade);
                            break;

                        case CrudType.Update:
                            repository.Update(presenter.Unidade);
                            break;
                        }
                        SearchCommand.Execute(this);
                    }
                    else
                    {
                        if (action == CrudType.Update)
                        {
                            SearchCommand.Execute(this);
                        }
                    }
                }
            };

            IBreadCrumbPresenter breadCrumb = this._container.Resolve <IBreadCrumbPresenter>();

            if (breadCrumb != null)
            {
                breadCrumb.AddCrumb(action.GetDescription(), presenter);
            }
        }
 public void SetPresenter(IUnitPresenter presenter)
 {
     this.DataContext = presenter;
 }
Example #3
0
 void Awake()
 {
     _presenter = new UnitPresenter(this);
     _presenter.Initialize();
 }