public void UpdateTaskIdx(string taskId, string key, string tasklistId) { List<TaskIdx> taskIdxs = null; if (IsolatedStorageSettings.ApplicationSettings.Contains(Constant.USERNAME_KEY)) { string username = IsolatedStorageSettings.ApplicationSettings[Constant.USERNAME_KEY] as string; taskIdxs = this._context.TaskIdxs .Where(o => o.TasklistId.Equals(tasklistId) && o.AccountId.Equals(username)) .ToList(); } else { taskIdxs = this._context.TaskIdxs .Where(o => o.TasklistId.Equals(tasklistId) && o.AccountId.Equals("")) .ToList(); } if (taskIdxs != null) { foreach (var taskIdx in taskIdxs) { JArray indexesArray = null; JArray newIndexesArray = null; indexesArray = (JArray)taskIdx.Indexes.ToJSONObject(); newIndexesArray = new JArray(); for (int i = 0; i < indexesArray.Count; i++) { string currentTaskId = indexesArray[i].Value<string>(); if (!currentTaskId.Equals(taskId)) { newIndexesArray.Add(currentTaskId); } } if (taskIdx.Key.Equals(key)) { newIndexesArray.Add(taskId); } taskIdx.Indexes = newIndexesArray.ToJSONString(); } if (taskIdxs.Count > 0) { this._context.SubmitChanges(); } } }