Пример #1
0
        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;
        }
Пример #2
0
        public AddEditTypeModel()
        {
            mIssueType = new IssueType {IsActive = true};

            OkButtonCommand = new DelegateCommand<object>(OkButtonHander, CanExecuteOkButtonHandler);
            CancelButtonCommand = new DelegateCommand<object>(CancelButtonHander, CanExecuteOkButtonHandler);
        }
        public AddExistingMilestoneTypeDialog(IssueType issueType)
        {
            InitializeComponent();

            var model = new AddExistingMilestoneTypeViewModel(issueType);
            model.Loaded +=
                () =>
                {
                    model.View = this;
                    DataContext = model;
                    Utils.ResetOriginalValues(this);
                };
        }
        public AddExistingIssueSubTypeViewModel(IssueType issueType)
        {
            mIssueType = issueType;

            OkButtonCommand = new DelegateCommand<object>(OkButtonHander, CanModify);
            CancelButtonCommand = new DelegateCommand<object>(CancelButtonHander, x => true);

            CmsWebServiceClient cmsWebServiceClient = new CmsWebServiceClient(Utils.WcfBinding, Utils.WcfEndPoint);
            IssueSubTypes = new List<IssueSubType>();

            cmsWebServiceClient.GetNewIssueSubTypesAvailableForIssueTypeCompleted += (s, e) =>
            {
                IssueSubTypes = e.Result;

                if (Loaded!=null)
                {
                    Loaded();
                }

                RaisePropertyChanged("IssueSubTypes");
            };
            cmsWebServiceClient.GetNewIssueSubTypesAvailableForIssueTypeAsync(issueType.Id);
        }
Пример #5
0
 public IssueWorkflowViewModel(IssueStatus issueStatus, IssueType issueType)
 {
     mIssueStatus = issueStatus;
     mIssueType = issueType;
     LoadData();
 }
Пример #6
0
        public void ImportIssueType()
        {
            mForm.AddMessage(MessageType.Info, "-------------------- Importing Issue Type --------------------");
            List<IssueType> Types = (from x in mOldIssuesDataContext.IssueTypes select x).ToList();

            foreach (var Type in Types)
            {
                CmsEquipmentDatabase.CmsWebService.IssueType newType = new CmsEquipmentDatabase.CmsWebService.IssueType()
                {
                    Name = Type.Name,
                    Ordinal = Type.Ordinal
                };

                var typeExist = (from x in mCee.IssueTypes where x.Name == newType.Name select x).FirstOrDefault();

                if (typeExist == null)
                {
                    string message = String.Format("Adding Issue Type '{0}'", newType.Name);
                    mForm.AddMessage(MessageType.Info, message);
                    mCee.IssueTypes.AddObject(newType);
                }
                else
                {
                    string message = String.Format("Issue Type '{0}' already exist, skipping", typeExist.Name);
                    mForm.AddMessage(MessageType.Warning, message);
                }
            }
            mCee.SaveChanges();
        }
        public void LoadModel()
        {
            mIssueTypes = CMS.Cache.IssueTypes.ToList();
            IssueType allType = new IssueType { Id = -1, Name = "All" };
            mIssueTypes.Insert(0, allType);
            mSelectedType = allType;
            RaisePropertyChanged("IssueTypes");

            mIssueCategories = new List<IssueCategory>();//  CMS.Cache.IssueCategories.ToList();
            //Only add categories that are assigned to the issue
            mIssueAssignedCategories.ForEach(x => mIssueCategories.Add(CMS.Cache.IssueCategories.FirstOrDefault(y => y.Id == x.IssueCategoryId) ));
            IssueCategory allCategory = new IssueCategory { Id = -1, Name = "All" };
            mIssueCategories.Insert(0, allCategory);
            mSelectedCategory = allCategory;

            RaisePropertyChanged("IssueCategories");

            CmsWebServiceClient cmsWebServiceClient = new CmsWebServiceClient(Utils.WcfBinding, Utils.WcfEndPoint);
            cmsWebServiceClient.GetIssueStandardActionsCompleted += (s, e) =>
            {
                var issueCategoriesIds = mIssueCategories.Select(x => x.Id);
                    var result = e.Result;
                    if (result != null)
                    {
                        StandardActions = result.Where(x => issueCategoriesIds.Contains(x.IssueCategoryId)).ToList();
                    }
                    mStandardActionsLoaded = true;
                    RaiseLoaded();
                };
            cmsWebServiceClient.GetIssueStandardActionsAsync();
        }
Пример #8
0
        public IssueType SaveIssueType(IssueType issueType)
        {
            using (var cee = new CmsEntities())
            {
                //Check if the pipe area exist
                IssueType originalObject = (from x in cee.IssueTypes where x.Id == issueType.Id select x).FirstOrDefault();

                if (originalObject == null)
                {
                    if (String.IsNullOrEmpty(issueType.Code))
                    {
                        issueType.Code = issueType.Name.Replace(" ", "");
                    }
                    //Add new Issue Type
                    cee.IssueTypes.Add(issueType);
                }
                else
                {
                    //Update existing Type
                    originalObject.Name = issueType.Name;
                    originalObject.Description = issueType.Description;
                    originalObject.Ordinal = issueType.Ordinal;
                }

                cee.SaveChanges();
            }
            return issueType;
        }
Пример #9
0
 void cmsWebServiceClient_GetIssueTypeCompleted(object sender, GetIssueTypeCompletedEventArgs e)
 {
     mIssueType = e.Result;
     DataLoaded();
 }