public static async void AddTask(string description) { if (App.CurrentUserID != -1) { DateTime currentTime = DateTime.Now; // 上传一个起止时间相同的时间记录,表明有这个任务 TomatoTime time = new TomatoTime() { BeginTime = currentTime.ToString("yyyy-MM-dd HH:mm:ss"), EndTime = currentTime.ToString("yyyy-MM-dd HH:mm:ss"), UserId = App.StaticUser.UserId, Description = description, BeginTimeDate = currentTime.Date.ToShortDateString(), SpanString = currentTime.ToShortTimeString() + " → " + currentTime.ToShortTimeString() }; await App.TomatoTimeManager.AddTomatoTimeTaskAsync(time); await App.UserManager.ModifyUserTaskAsync(App.StaticUser); } TomatoTask tomatoTask = new TomatoTask(); tomatoTask.TaskName = description; tomatoTask.TimeRecords = new List <TomatoTime>(); tomatoTask.TotalTimes = new TimeSpan(); tasks.Insert(0, tomatoTask); RecordCountChanged(); }
public void AddTimeRecord(TomatoTime tomatoTime) { string key = tomatoTime.Description; if (!UserTomatoTimes.ContainsKey(key)) { UserTomatoTimes.Add(key, new List <TomatoTime>()); } UserTomatoTimes[key].Insert(0, tomatoTime); }
public static void AddTimeRecord(TomatoTime tomatoTime) { var tempTasks = new List <TomatoTask>(); for (int i = 0; i < tasks.Count; i++) { if (tasks[i].TaskName == tomatoTime.Description) { tasks[i].TimeRecords.Insert(0, tomatoTime); tasks[i].TotalTimes += Convert.ToDateTime(tomatoTime.EndTime) - Convert.ToDateTime(tomatoTime.BeginTime); } tempTasks.Add(tasks[i]); } tasks.Clear(); tempTasks.ForEach(g => tasks.Add(g)); }
public async Task AddTomatoTimeAsync(TomatoTime tomatoTime) { var uri = new Uri(string.Format(Constants.TomatoTimeUrl, string.Empty)); try { var json = JsonConvert.SerializeObject(tomatoTime); var content = new StringContent(json, Encoding.UTF8, "application/json"); HttpResponseMessage response = null; response = await _client.PostAsync(uri, content); } catch (Exception ex) { Debug.WriteLine(@"\tERROR {0}", ex.Message); } }
public Task AddTomatoTimeTaskAsync(TomatoTime tomatoTime) { return(restService.AddTomatoTimeAsync(tomatoTime)); }
public AddTimeRecordViewModel() { tomatoTime = new TomatoTime(); }