/// <summary> /// /// </summary> /// <remarks></remarks> /// <seealso cref=""/> /// <param name="value"></param> /// <returns></returns> public static string Encode(string value) { string encodedValue = value; // has special characters if (RegExHelper.IsMatch(value, RegExHelper.LUCENE_INVALID_CHARS_REGEX)) { encodedValue = ReplaceSpecialCharacters(value); } return(encodedValue); }
private bool unitValidation(Unit unit, long[] checkedRecords, UnitManager unitManager) { bool check = true; List <Unit> unitList = unitManager.Repo.Get().ToList();; if (unit.Name == null || unit.Name == "") { Session["nameMsg"] = "invalid Name"; check = false; } else { bool nameExist = !(unitList.Where(p => p.Name.ToLower().Equals(unit.Name.ToLower())).Count().Equals(0)); if (nameExist) { Unit tempUnit = unitList.Where(p => p.Name.ToLower().Equals(unit.Name.ToLower())).ToList().First(); if (unit.Id != tempUnit.Id) { Session["nameMsg"] = "Name already exist"; check = false; } else { Session["nameMsg"] = null; } } else { Session["nameMsg"] = null; } } if (unit.Abbreviation == null || unit.Abbreviation == "") { Session["abbrMsg"] = "invalid Abbreviation"; check = false; } else { bool abbreviationExist = !(unitList.Where(p => p.Abbreviation.ToLower().Equals(unit.Abbreviation.ToLower())).Count().Equals(0)); if (abbreviationExist) { Unit tempUnit = unitList.Where(p => p.Abbreviation.ToLower().Equals(unit.Abbreviation.ToLower())).ToList().First(); if (unit.Id != tempUnit.Id) { Session["abbrMsg"] = "Abbreviation already exist"; check = false; } else { Session["abbrMsg"] = null; } } else { Session["abbrMsg"] = null; } } if (checkedRecords != null) { Session["dataTypeMsg"] = null; } else { Session["dataTypeMsg"] = "Choose at least one Data Type."; check = false; } if (!String.IsNullOrEmpty(unit.Dimension.Name) && unit.Dimension.Name != "Select or Enter") { Session["dimensionMsg"] = null; } else { Session["dimensionMsg"] = "Select or create an Dimension."; check = false; } if ((!String.IsNullOrEmpty(unit.Dimension.Specification) && RegExHelper.IsMatch(unit.Dimension.Specification, RegExHelper.DIMENSION_SPECIFICATION)) || String.IsNullOrEmpty(unit.Dimension.Specification)) { Session["dimensionSpecificationMsg"] = null; } else { Session["dimensionSpecificationMsg"] = "not valid."; check = false; } return(check); }