public static ChecklistItem ConvertServerToLocal(ChecklistItem serverItem)
 {
     ChecklistItem item = new ChecklistItem();
     // server status : NORMAL = 0; DONE = 1; ARCHIVED = 2;
     item.Checked = serverItem.Status;
     item.Title = serverItem.Title;
     item.SortOrder = serverItem.SortOrder;
     item.SId = serverItem.SId;
     return item;
 }
 public static List<ChecklistItem> ConvertCheckListItemLocalToServer(List<ChecklistItem> checklistItems)
 {
     List<ChecklistItem> serverItems = new List<ChecklistItem>();
     foreach (ChecklistItem localItem in checklistItems)
     {
         ChecklistItem batchItem = new ChecklistItem();
         if (!localItem.IsDeletedForever())
         {
             //batchItem.Id = localItem.SId; // TODO 此处可能是个坑  后续:使用json转换工具之后,不必转换sid到id
             batchItem.SortOrder = localItem.SortOrder;
             batchItem.Title = localItem.Title;
             batchItem.Status = localItem.IsChecked ? Constants.CompletedStatus.DONE : Constants.CompletedStatus.NORMAL;
             serverItems.Add(batchItem);
         }
     }
     return serverItems;
 }
 public void SwitchToChecklist(Tasks task)
 {
     List<ChecklistItem> items = new List<ChecklistItem>();
     String content = task.Content;
     if (content.Contains("\n"))
     {
         if (content.Contains("\r\n"))
         {
             //先统一替换成线上版本
             content = content.Replace("\r\n", "\n");
         }
         //然后替换成C#版本
         content = content.Replace("\n", "\r\n");
     }
     if (!string.IsNullOrEmpty(content))
     {
         String[] arrayTitle = content.Split(new string[] { "\r\n" }, StringSplitOptions.None);
         for (int i = 0, size = arrayTitle.Length; i < size; i++)
         {
             if (i == 0 && string.IsNullOrEmpty(arrayTitle[i]))
             {
                 continue;
             }
             String itemTitle = string.IsNullOrEmpty(arrayTitle[i]) ? "" : arrayTitle[i];
             ChecklistItem item = new ChecklistItem();
             //item.Id = GetDefaultItemId();// TODO 为什么要改变Id
             item.Title = itemTitle;
             item.TaskId = task.Id;
             items.Add(item);
         }
     }
     else
     {
         items.Add(new ChecklistItem { Title = string.Empty, TaskId = task.Id });
     }
     task.ChecklistItems = items;
 }
 public void AddNewCheckListItemByEnterKeyDown()
 {
     var checkListItem = new ChecklistItem
     {
         Checked = ModelStatusEnum.NOT_COMPLETED,
         CreatedTime = DateTime.UtcNow,
         Deleted = ModelStatusEnum.DELETED_NO,
         Title = string.Empty
     };
     TrulyCheckListItems.Add(checkListItem);
 }