async Task <string> SendApprovalRequest(CalendarDate cDate) { var payload = $"{{\"calendarDate\":\"{cDate.StampAt.ToString()}\"}}"; var content = new StringContent(payload, Encoding.UTF8, "application/json"); var response = await client.PostAsync(Variables.ApprovalRequestURL, content); return(await response.Content.ReadAsStringAsync()); }
public async Task SaveCalendarDateAsync(CalendarDate cDate) { if (cDate.Id == null) { await calendarDateTable.InsertAsync(cDate); } else { await calendarDateTable.UpdateAsync(cDate); } }
async void Handle_OnCalendarTapped(object snder, EventArgs e) { var ev = ((CalendarTappedEventArgs)e); var cev = calendarEventCollection.Where(ce => ce.StartTime.Year == ev.datetime.Year && ce.StartTime.Month == ev.datetime.Month && ce.StartTime.Day == ev.datetime.Day).SingleOrDefault(); // スタンプの申請中、承認、却下状態であればクリックを無視する if (cev?.Color != null) { return; } var result = await DisplayAlert("参加スタンプをリクエストしますか?", "", "はい", "いいえ"); if (result) { var cDate = new CalendarDate() { StampAt = ev.datetime, Type = CalendarDate.Status.Reviewing, }; try { IsRequesting(true); // カレンダー日付をRequestingに更新するのに成功し、 // 承認リクエストメールの送信に失敗したら永久にRequestingのままな実装 await cDateManager.SaveCalendarDateAsync(cDate); await SendApprovalRequest(cDate); IsRequesting(false); } catch (Exception ex) { Debug.Write(ex); } UpdateEvents(((CalendarTappedEventArgs)e).datetime); } }