public AddEditIssueRewardModel() { CompositionInitializer.SatisfyImports(this); mIssueReward = new IssueReward(); OkButtonCommand = new DelegateCommand<object>(OkButtonHander, CanExecuteOkButtonHandler); CancelButtonCommand = new DelegateCommand<object>(CancelButtonHander, x => true); }
public AddEditIssueRewardModel(int issueRewardId) { if (DesignerProperties.IsInDesignTool) { return; } CompositionInitializer.SatisfyImports(this); CmsWebServiceClient cmsWebServiceClient = new CmsWebServiceClient(Utils.WcfBinding, Utils.WcfEndPoint); cmsWebServiceClient.GetIssueRewardCompleted += (s1, e1) => { mIssueReward = e1.Result; if (DataLoaded!=null) { DataLoaded(); } }; cmsWebServiceClient.GetIssueRewardAsync(issueRewardId); OkButtonCommand = new DelegateCommand<object>(OkButtonHander, CanExecuteOkButtonHandler); CancelButtonCommand = new DelegateCommand<object>(CancelButtonHander, x => true); }
public DbOperationResult<IssueReward> SaveIssueReward(IssueReward issueReward) { var result = new DbOperationResult<IssueReward>(); try { using (var cee = new CmsEntities()) { IssueReward originalObject = (from x in cee.IssueRewards where x.Id == issueReward.Id select x).FirstOrDefault(); if (originalObject == null) { cee.IssueRewards.Add(issueReward); cee.SaveChanges(); result.EntityResult = issueReward; } else { originalObject.Reward = issueReward.Reward; originalObject.Production = issueReward.Production; originalObject.ReturnDollar = issueReward.ReturnDollar; originalObject.IsActive = issueReward.IsActive; originalObject.Ordinal = issueReward.Ordinal; cee.SaveChanges(); result.EntityResult = originalObject; } } } catch (Exception ex) { return BuildOperationalErrorResults<IssueReward>(ex); } return result; }