public AddEditIssueMilestoneDelayTypeModel()
        {
            mIssueMilestoneDelayType = new IssueMilestoneDelayType();

            OkButtonCommand = new DelegateCommand<object>(OkButtonHander, CanExecuteOkButtonHandler);
            CancelButtonCommand = new DelegateCommand<object>(CancelButtonHander, CanExecuteOkButtonHandler);
        }
        public DbOperationResult<IssueMilestoneDelayType> SaveIssueMilestoneDelayType(IssueMilestoneDelayType issueMilestoneDelayType)
        {
            var operationResult = new DbOperationResult<IssueMilestoneDelayType>();

            using (var cee = new CmsEntities())
            {
                IssueMilestoneDelayType originalObject = (from x in cee.IssueMilestoneDelayTypes where x.Id == issueMilestoneDelayType.Id select x).FirstOrDefault();

                if (originalObject == null)
                {
                    //Add new Issue Type
                    issueMilestoneDelayType.IsActive = true;
                    cee.IssueMilestoneDelayTypes.Add(issueMilestoneDelayType);
                    operationResult.EntityResult = issueMilestoneDelayType;
                }
                else
                {
                    //Update existing Type
                    originalObject.Code = issueMilestoneDelayType.Code;
                    originalObject.Description = issueMilestoneDelayType.Description;
                    originalObject.Ordinal = issueMilestoneDelayType.Ordinal;
                    operationResult.EntityResult = originalObject;
                }

                cee.SaveChanges();
            }

            return operationResult;
        }
 private void cmsWebServiceClient_GetIssueMilestoneDelayTypeCompleted(object sender, GetIssueMilestoneDelayTypeCompletedEventArgs e)
 {
     mIssueMilestoneDelayType = e.Result;
     DataLoaded(null);
 }
        private void LoadData(bool inEditMode)
        {
            var getIssueTrendNoticeStatuses = DatabaseLoader.GetIssueTrendNoticeStatuses();
            var getIssueMilestoneDelayTypes = DatabaseLoader.GetIssueMilestoneDelayTypes();
            var getIssueFinancialVarianceCodes = DatabaseLoader.GetIssueFinancialVarianceCodes();
            var getVendorsTask = DatabaseLoader.GetVendors();

            var tasks = new List<Task>
            {
                getIssueTrendNoticeStatuses,
                getIssueMilestoneDelayTypes,
                getIssueFinancialVarianceCodes,
                getVendorsTask
            };

            Task.Factory.ContinueWhenAll(tasks.ToArray(), x =>
            {
                CMS.UiFactory.StartNew(() =>
                {
                    Statuses = getIssueTrendNoticeStatuses.Result;
                    RaisePropertyChanged("Statuses");
                    RaisePropertyChanged("Status");

                    IssueMilestoneDelayTypes = getIssueMilestoneDelayTypes.Result;
                    IssueMilestoneDelayType no_selection = new IssueMilestoneDelayType { Id = -1, Code = NO_SELECTION };
                    IssueMilestoneDelayTypes.Insert(0, no_selection);

                    RaisePropertyChanged("IssueMilestoneDelayTypes");
                    RaisePropertyChanged("SelectedIssueMilestoneDelayType");

                    IssueFinancialVarianceCodes = getIssueFinancialVarianceCodes.Result;
                    IssueFinancialVarianceCode noCode = new IssueFinancialVarianceCode { Id = -1, Code = NO_SELECTION };
                    IssueFinancialVarianceCodes.Insert(0, noCode);

                    RaisePropertyChanged("IssueFinancialVarianceCodes");
                    RaisePropertyChanged("SelectedFinancialVarianceCode");

                    Vendors = getVendorsTask.Result;
                    if (!inEditMode)
                    {
                        SelectedVendor = (from v in Vendors where v.Name.Equals(NO_SELECTION, StringComparison.CurrentCultureIgnoreCase) select v).FirstOrDefault();
                        SelectedIssueMilestoneDelayType = (from v in IssueMilestoneDelayTypes where v.Code.Equals(NO_SELECTION, StringComparison.CurrentCultureIgnoreCase) select v).FirstOrDefault();
                        SelectedFinancialVarianceCode = (from v in IssueFinancialVarianceCodes where v.Code.Equals(NO_SELECTION, StringComparison.CurrentCultureIgnoreCase) select v).FirstOrDefault();
                    }

                    RaisePropertyChanged("Vendors");
                    RaisePropertyChanged("SelectedVendor");

                    if (ViewModelLoaded != null) ViewModelLoaded();
                });
            });
        }