public void EditCharacteristics(string id, string charName, string charValue, string oldN, string oldV) { MongodbFunctions mongo = new MongodbFunctions(); ObjectId objID = new ObjectId(id); Databases.DomainModel.Product product = mongo.GetProduct(objID); List <string> chars = product.Characteristics; string newChar = charName + ":" + charValue; if (oldN.Equals("") || oldV.Equals("")) { chars.Add(newChar); } else { int index = chars.IndexOf(oldN + ":" + oldV); chars.RemoveAt(index); chars.Insert(index, newChar); } mongo.UpdateCharacteristics(objID, chars); }