public AddEditIssueEffortModel()
        {
            CompositionInitializer.SatisfyImports(this);

            mIssueEffort = new IssueEffort();

            OkButtonCommand = new DelegateCommand<object>(OkButtonHander, CanExecuteOkButtonHandler);
            CancelButtonCommand = new DelegateCommand<object>(CancelButtonHander, x => true);
        }
        public AddEditIssueEffortModel(int issueEffortId)
        {
            if (DesignerProperties.IsInDesignTool) { return; }
            CompositionInitializer.SatisfyImports(this);

            CmsWebServiceClient cmsWebServiceClient = new CmsWebServiceClient(Utils.WcfBinding, Utils.WcfEndPoint);

            cmsWebServiceClient.GetIssueEffortCompleted += (s1, e1) =>
                {
                    mIssueEffort = e1.Result;
                    if (DataLoaded!=null)
                    {
                        mIssueEffort = e1.Result;
                        DataLoaded();
                    }
                };
            cmsWebServiceClient.GetIssueEffortAsync(issueEffortId);

            OkButtonCommand = new DelegateCommand<object>(OkButtonHander, CanExecuteOkButtonHandler);
            CancelButtonCommand = new DelegateCommand<object>(CancelButtonHander, x => true);
        }
        private void OkButtonHander(object parameter)
        {
            if (CanExecuteOkButtonHandler(parameter))
            {
                if (AreAllValid())
                {
                    CmsWebServiceClient cmsWebServiceClient = new CmsWebServiceClient(Utils.WcfBinding, Utils.WcfEndPoint);

                    cmsWebServiceClient.SaveIssueEffortCompleted +=
                        (s1, e1) =>
                        {
                            View.SavedIssueEffort = e1.Result.EntityResult;
                            mIssueEffort = e1.Result.EntityResult;
                            View.DialogResult = true;
                        };
                    cmsWebServiceClient.SaveIssueEffortAsync(mIssueEffort);
                }
            }
        }
示例#4
0
        public DbOperationResult<IssueEffort> SaveIssueEffort(IssueEffort issueEffort)
        {
            var result = new DbOperationResult<IssueEffort>();

            try
            {
                using (var cee = new CmsEntities())
                {
                    IssueEffort originalObject = (from x in cee.IssueEfforts where x.Id == issueEffort.Id select x).FirstOrDefault();

                    if (originalObject == null)
                    {
                        cee.IssueEfforts.Add(issueEffort);
                        cee.SaveChanges();
                        result.EntityResult = issueEffort;
                    }
                    else
                    {
                        originalObject.Effort = issueEffort.Effort;
                        originalObject.Description = issueEffort.Description;
                        originalObject.IsActive = issueEffort.IsActive;
                        originalObject.Ordinal = issueEffort.Ordinal;
                        cee.SaveChanges();
                        result.EntityResult = originalObject;
                    }
                }
            }
            catch (Exception ex)
            {
                return BuildOperationalErrorResults<IssueEffort>(ex);
            }

            return result;
        }