예제 #1
0
        /// <summary>
        /// 完成待办事项
        /// </summary>
        /// <param name="id">待办事项的ID</param>
        /// <returns></returns>
        private async Task CompleteTodo(string id)
        {
            try
            {
                var currentMemo = MyToDos.ElementAt(MyToDos.ToList().FindIndex(sch =>
                {
                    if (sch.ID == id)
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }));
                currentMemo.IsDone = !currentMemo.IsDone;

                await SerializerHelper.SerializerToJson <ObservableCollection <ToDo> >(MyToDos, "myschedules.sch", true);

                if (!App.isInOfflineMode)
                {
                    var isDone = await PostHelper.FinishSchedule(id, currentMemo.IsDone? "1" : "0");

                    if (isDone)
                    {
                        await PostHelper.SetMyOrder(LocalSettingHelper.GetValue("sid"), ToDo.GetCurrentOrderString(MyToDos));

                        Messenger.Default.Send(new GenericMessage <ObservableCollection <ToDo> >(MyToDos), MessengerTokens.UpdateTile);
                    }
                }
                else
                {
                    Messenger.Default.Send(new GenericMessage <ObservableCollection <ToDo> >(MyToDos), MessengerTokens.UpdateTile);
                }
            }
            catch (Exception e)
            {
                var task = ExceptionHelper.WriteRecord(e);
            }
        }