private void Button_Click(object sender, RoutedEventArgs e) { var formatter = new BinaryFormatter(); switch (ActionId) { case ActionName.Doing: var DoingClass = new Doing(Time.SelectedDate.Value, ActionNameText.Text); using (var fs = new FileStream(FileName, FileMode.OpenOrCreate)) { formatter.Serialize(fs, DoingClass); } break; case ActionName.NeedToDo: var NeedToDoClass = new NeedToDo(Time.SelectedDate.Value, ActionNameText.Text); using (var fs = new FileStream(FileName, FileMode.OpenOrCreate)) { formatter.Serialize(fs, NeedToDoClass); } break; case ActionName.Done: var DoneClass = new Done(Time.SelectedDate.Value, ActionNameText.Text); using (var fs = new FileStream(FileName, FileMode.OpenOrCreate)) { formatter.Serialize(fs, DoneClass); } break; } }
public async Task <ActionResult <NeedToDo> > Post([FromBody] NeedToDo value) { var result = await db.NeedToDo.FirstOrDefaultAsync(s => s.NeedToDoId == value.NeedToDoId && s.StudentId == value.StudentId); try { result.Hide = value.Hide; result.Time = value.Time; result.Finish = value.Finish; result.Content = value.Content; result.Extra = value.Extra; await db.SaveChangesAsync(); } catch { return(BadRequest()); } return(Ok()); }
public async Task <ActionResult> Put([FromBody] NeedToDo vaule) { var td = new NeedToDo(); try{ td.StudentId = vaule.StudentId; td.Content = vaule.Content; td.Hide = vaule.Hide; td.Time = vaule.Time; td.Finish = vaule.Finish; td.Extra = vaule.Extra; await db.NeedToDo.AddAsync(td); await db.SaveChangesAsync(); } catch { return(BadRequest()); } return(Ok()); }