/// <summary> /// Method to Add Category. /// </summary> /// <param name="CategoryName"></param> /// <param name="requestorID"></param> /// <returns></returns> public string AddCategory(string CategoryName, string requestorID) { #region Business Logic string updated = "Unable to add category"; try { Category objCategory = repoObj.List<Category>(x => x.name.Equals(CategoryName)).FirstOrDefault(); if (objCategory == null) { objCategory = new Category(); objCategory.id = Guid.NewGuid(); objCategory.name = CategoryName; objCategory.status = SystemStatements.STATUS_ACTIVE; objCategory.requestedById = new Guid(requestorID); repoObj.Create<Category>(objCategory); updated = "Category has been added successfully"; } else { updated = "Category already exist"; } } catch (Exception ex) { WriteError(ex); } return updated; #endregion }
private void FixupCategory1(Category previousValue) { if (previousValue != null && previousValue.SubCategories1.Contains(this)) { previousValue.SubCategories1.Remove(this); } if (Category1 != null) { if (!Category1.SubCategories1.Contains(this)) { Category1.SubCategories1.Add(this); } if (parentId != Category1.id) { parentId = Category1.id; } } else if (!_settingFK) { parentId = null; } }
private void FixupCategory(Category previousValue) { if (previousValue != null && previousValue.SubCategories.Contains(this)) { previousValue.SubCategories.Remove(this); } if (Category != null) { if (!Category.SubCategories.Contains(this)) { Category.SubCategories.Add(this); } if (childId != Category.id) { childId = Category.id; } } else if (!_settingFK) { childId = null; } }