private string GetNextConstraintId(ContraintGroups group) { string abbr = Properties.Resources.ResourceManager.GetString(group.ToString()).ToUpper()[0].ToString(); string first = abbr + "1"; if (Constraints == null || Constraints.Count == 0) return first; int? n = Constraints.Where(c => c.ConstraintGroup==(short)group).Count(); if(!n.HasValue) return first; return abbr + (n + 1); }
private void AddConstraint(string constraintText, ContraintGroups group, double factor) { ProjectConstraint constraint = new ProjectConstraint() { ConstraintUId = System.Guid.NewGuid().ToString(), ProjectUId = Project.ProjectUId, Constraint = constraintText, AdjustPointFactor = factor, ConstraintGroup = (short) group, ConstraintId = GetNextConstraintId(group) }; executor.StartBackgroundTask( () => { constraintsService.AddProjectConstraint(Project.ProjectUId, constraint); }, () => { Constraints.Add(constraint); NewConstraint = ""; }); }