public DbOperationResult<IssueTypeSubType> AddIssueTypeSubType(IssueType issueType, IssueSubType issueSubType) { var result = new DbOperationResult<IssueTypeSubType>(); //guard against duplicate. using (var cee = new CmsEntities()) { int k = (from x in cee.IssueTypeSubTypes where x.IssueTypeId == issueType.Id && x.IssueSubTypeId == issueSubType.Id select x.Id).Count(); if (k > 0) { result.ServerErrorMessages.Add(string.Format("Insert Failed. An IssueTypeSubType with the combination IssueType Name: '{0}' and Issue SubType Name: '{1}' already exists.", issueType.Name, issueSubType.Name)); return result; } var typeSubType = new IssueTypeSubType { IssueSubTypeId = issueSubType.Id, IssueTypeId = issueType.Id, Ordinal = 0 }; cee.IssueTypeSubTypes.Add(typeSubType); cee.SaveChanges(); result.EntityResult = typeSubType; } return result; }
public AddEditIssueSubTypeModel() { mIssueSubType = new IssueSubType {IsActive = true}; mIssueSubTypeLoaded = true; var cmsWebServiceClient = new CmsWebServiceClient(Utils.WcfBinding, Utils.WcfEndPoint); cmsWebServiceClient.GetAllIssueSubTypesCompleted += (s1, e1) => { ExistingIssueSubTypes = e1.Result; mExistingIssueSubTypesLoaded = true; OnDataLoaded(); }; cmsWebServiceClient.GetAllIssueSubTypesAsync(); OkButtonCommand = new DelegateCommand<object>(OkButtonHander, CanExecuteOkButtonHandler); CancelButtonCommand = new DelegateCommand<object>(CancelButtonHander, CanExecuteOkButtonHandler); }
private void BuildOptions() { IssueSubType option = new IssueSubType { Checked = false, Name = "Name",Description = "Name"}; IssueSubType option1 = new IssueSubType { Checked = false, Name = "Description", Description = "Description" }; IssueSubType option2 = new IssueSubType { Checked = false, Name = "Reason", Description = "Reason" }; IssueSubType option3 = new IssueSubType { Checked = false, Name = "Solution", Description = "Solution" }; IssueSubType option4 = new IssueSubType { Checked = false, Name = "IssueType", Description = "Issue Type" }; IssueSubType option5 = new IssueSubType { Checked = false, Name = "IssueSubType", Description = "Issue Sub Type" }; IssueSubType option6 = new IssueSubType { Checked = false, Name = "Classification", Description = "Classification" }; IssueSubType option7 = new IssueSubType { Checked = false, Name = "Priority", Description = "Priority" }; IssueSubType option8 = new IssueSubType { Checked = false, Name = "Categories", Description = "Categories" }; IssueSubType option9 = new IssueSubType { Checked = false, Name = "Areas", Description = "Areas" }; IssueSubType option10 = new IssueSubType { Checked = false, Name = "Overrides", Description = "Overrides" }; IssueSubType option11 = new IssueSubType { Checked = false, Name = "RequestedBy", Description = "Requested By" }; IssueSubType option12 = new IssueSubType { Checked = false, Name = "KeyStakeholder", Description = "Key Stakeholder" }; mOptions.Add(option); mOptions.Add(option1); mOptions.Add(option2); mOptions.Add(option3); mOptions.Add(option4); mOptions.Add(option5); mOptions.Add(option6); mOptions.Add(option7); mOptions.Add(option8); mOptions.Add(option9); mOptions.Add(option10); mOptions.Add(option11); mOptions.Add(option12); RaisePropertyChanged("Options"); OnDataLoaded(); }
private DbOperationResult<IssueSubType> UpdateIssueSubType(IssueSubType issueSubType) { var result = new DbOperationResult<IssueSubType>(); using (var cee = new CmsEntities()) { int k = (from x in cee.IssueSubTypes where x.Name.Equals(issueSubType.Name, StringComparison.CurrentCultureIgnoreCase) && x.Id != issueSubType.Id select x.Id).Count(); if (k > 0) { result.ServerErrorMessages.Add(string.Format("Save Failed. An IssueSubType with the Name '{0}' already exists.", issueSubType.Name)); } IssueSubType dbMatch = (from x in cee.IssueSubTypes where x.Id == issueSubType.Id select x).FirstOrDefault(); if (dbMatch == null) { result.ServerErrorMessages.Add(string.Format("Save Failed. ssueSubType with the Id '{0}' does not exist.", issueSubType.Id)); return result; } dbMatch.Name = issueSubType.Name; dbMatch.Description = issueSubType.Description; dbMatch.Code = issueSubType.Code; dbMatch.Ordinal = issueSubType.Ordinal; cee.SaveChanges(); result.EntityResult = dbMatch; } return result; }
private DbOperationResult<IssueSubType> InsertIssueSubType(IssueSubType issueSubType) { var result = new DbOperationResult<IssueSubType>(); //guard against duplicate. using (var cee = new CmsEntities()) { int k = (from x in cee.IssueSubTypes where x.Name.Equals(issueSubType.Name, StringComparison.CurrentCultureIgnoreCase) select x.Id).Count(); if (k > 0) { result.ServerErrorMessages.Add(string.Format("Insert Failed. An IssueSubType with the Name '{0}' already exists.", issueSubType.Name)); } cee.IssueSubTypes.Add(issueSubType); cee.SaveChanges(); result.EntityResult = issueSubType; } return result; }
public DbOperationResult<IssueSubType> SaveIssueSubType(IssueSubType issueSubType) { try { if (issueSubType.Id == 0) { return InsertIssueSubType(issueSubType); } return UpdateIssueSubType(issueSubType); } catch (Exception ex) { return BuildOperationalErrorResults<IssueSubType>(ex); } }