public ToDoLists AddToDo(ToDoLists item) { if (item == null) { throw new ArgumentNullException("item"); } db.ToDoLists.Add(item); db.SaveChanges(); return(item); }
public bool EditToDo(ToDoLists item) { try { db.Entry(item).State = EntityState.Modified; db.SaveChanges(); return(true); } catch (Exception e) { return(false); } }
public bool DeleteToDo(int id) { try { ToDoLists ToDoLists = db.ToDoLists.Find(id); db.ToDoLists.Remove(ToDoLists); db.SaveChanges(); return(true); } catch (Exception e) { return(false); } }
public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ToDoLists toDoLists = _toDosServices.GetToDoByID(Convert.ToInt32(id)); if (toDoLists == null) { return(HttpNotFound()); } return(View(toDoLists)); }
public ActionResult Create([Bind(Include = "ID,Definition,DueDate,Priority,Attribute,Reminders")] ToDoLists ToDoList) { if (ModelState.IsValid) { try { _toDosServices.AddToDo(ToDoList); return(RedirectToAction("Index")); } catch (Exception e) { return(View("Error", new HandleErrorInfo(e, "ToDoLists", "Create"))); } } return(View(ToDoList)); }
public ActionResult Edit([Bind(Include = "ID,Definition,DueDate,Priority,Attribute")] ToDoLists toDoLists) { if (ModelState.IsValid) { try { bool edit = _toDosServices.EditToDo(toDoLists); if (edit) { return(RedirectToAction("Index")); } } catch (Exception e) { return(View("Error", new HandleErrorInfo(e, "ToDoLists", "Edit"))); } } return(View(toDoLists)); }
public void button_Click(object sender, EventArgs e) { switch (fun) { case 1: Form1.getInstance().ShowTypeNote(); //Form1.getInstance().NewNote(); break; case 2: //edit if (Form1.type == 0) { MessageBox.Show("Vui lòng thử lại", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { switch (Form1.type) { case 1: Notes a = DataHandle.getInstance().GetDataFromNote(); Form1.getInstance().editNote(a.Tittle, a.Content); break; case 2: ToDoLists b = DataHandle.getInstance().GetDataToDoList(); if (b == null) { MessageBox.Show("Choose note to edit", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { Form1.getInstance().editToDoList(b.Tittle, b.item); } break; case 3: Reminders c = DataHandle.getInstance().GetDateReminder(); if (c == null) { MessageBox.Show("Choose note to edit", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { Form1.getInstance().EditReminder(c.Tittle, c.Content, c.Time, c.Check); } break; } } break; case 3: //delete if (Form1.type == 0) { MessageBox.Show("Vui lòng thử lại", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { switch (Form1.type) { case 1: DataHandle.getInstance().DeleteNote(); DataHandle.getInstance().ShowNote(); break; case 2: DataHandle.getInstance().DeleteToDoList(); DataHandle.getInstance().ShowNote(); break; case 3: DataHandle.getInstance().DeleteReminder(); DataHandle.getInstance().ShowNote(); break; } } break; case 4: if (Form1.type == 0) { MessageBox.Show("Vui lòng thử lại", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { switch (Form1.type) { case 1: //note Notes a = DataHandle.getInstance().GetDataFromNote(); if (Connection.clientStatus == -1) { MessageBox.Show("No connection is found", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (Connection.clientStatus == 0) { Connection.DistributeNote(a); } else { Form1.connection.CSendNote(a); } break; case 2: //tdl break; case 3: //rmd Reminders rmd = DataHandle.getInstance().GetDateReminder(); if (Connection.clientStatus == -1) { MessageBox.Show("No connection is found", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (Connection.clientStatus == 0) { Connection.DistributeReminder(rmd); } else { Form1.connection.CSendReminder(rmd); } break; } } break; } }