Exemplo n.º 1
0
        /// <summary>
        /// Execute the click event of the button new
        /// </summary>
        private void ExecuteNewCommand()
        {
            Office office = new Office();
            OfficeViewModel officeViewModel = new OfficeViewModel();

            if (OfficeEditionRequested != null)
            {
                officeViewModel.OnSaveCompleted += Model_OnSaveCompleted;
                officeViewModel.Initialize(office,_context);
                OfficeEditionRequested(this, new ContextEditionEventArgs<OfficeViewModel>(officeViewModel));
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Execute when an office was loaded
        /// </summary>
        /// <param name="operation">Operation result</param>
        private void LoadOfficeCompleted(InvokeOperation<Office> operation)
        {
            HandleInvokeOperation(operation, delegate
            {
                _office = operation.Value;
                _documentcontext.Load(_documentcontext.GetDocumentsByCertificateIdQuery(Certificate.CertificateId), LoadBehavior.RefreshCurrent, LoadDocumentCompleted, null);

            });
        }
Exemplo n.º 3
0
 /// <summary>
 /// Edit the selected office
 /// </summary>
 /// <param name="item">user item</param>
 private void ExecuteEditCommand(Office office)
 {
     if (OfficeEditionRequested != null)
     {
         OfficeViewModel OfficeViewModel = new OfficeViewModel();
         OfficeViewModel.OnSaveCompleted += Model_OnSaveCompleted;
         OfficeViewModel.Initialize(office,_context,true);
         OfficeEditionRequested(this, new ContextEditionEventArgs<OfficeViewModel>(OfficeViewModel));
     }
 }
Exemplo n.º 4
0
        /// <summary>
        /// Initializes a new instance of the OfficeViewModel
        /// </summary>
        /// <param name="office">Office</param>
        /// <param name="context">Context</param>
        /// <param name="isEdit">is it new or a modification ?</param>
        public void Initialize(Office office, VocContext context,bool isEdit = false)
        {
            _context = context;
            Office = office;
            IsLocalOffice = true;
            IsRegionalOffice = false;
            if (!isEdit)
                Label = Strings.NewOffice;
            else
            {
                Label = Office.OfficeName;
                if (RegionalOfficeList.Any(x => x.OfficeId == office.OfficeId))
                {
                    var elementToRemove = RegionalOfficeList.First(x => x.OfficeId == office.OfficeId);
                    RegionalOfficeList.Remove(elementToRemove);
                }

                if (_office.OfficeType.Value == OfficeTypeEnum.LocalOffice)
                {
                    IsLocalOffice = false;
                    IsRegionalOffice = true;
                }
                else
                {
                    IsLocalOffice = true;
                    IsRegionalOffice = false;
                }
            }

            SetVisibility(false);
            if (App.CurrentUser.IsInRole(UserRoleEnum.Supervisor))
            {
                OfficeHeaderText = Strings.ViewOffice;
                OfficeInstructionsText = Strings.ViewOfficeInstructions;
                IsEnabled = false;
            }
            else
            {
                OfficeHeaderText = Strings.EditOffice;
                OfficeInstructionsText = Strings.EditOfficeInstructions;
                IsEnabled = true;
            }
        }