public ActionResult DeleteConfirmed(todoEstructure model) { todo myTodo = db.todos.Single(u => u.idTodo == model.IdTodo); db.todos.DeleteObject(myTodo); try { db.SaveChanges(); } catch { ModelState.AddModelError("", "It can't delete this TO-DO"); todoEstructure temp = new todoEstructure { IdTodo = myTodo.idTodo, nameTodo = myTodo.nombre, descriptionTodo = myTodo.descripcion, dateI = myTodo.fechaI, dateF = myTodo.fechaF, status = myTodo.status, userOwner = myTodo.userOwner }; return View(temp); } return RedirectToAction("MyToDo"); }
public ActionResult Delete(int id = 0) { todo myTodo = db.todos.Single(u => u.idTodo == id); todoEstructure temp = new todoEstructure { IdTodo = myTodo.idTodo, nameTodo = myTodo.nombre, descriptionTodo = myTodo.descripcion, dateI = myTodo.fechaI, dateF = myTodo.fechaF, status = myTodo.status, userOwner = myTodo.userOwner }; return View(temp); }
public ActionResult Edit(todoEstructure todo,string statusList) { System.Diagnostics.Debug.WriteLine("Estado: " + statusList); string valStatus = (statusList.Equals("Outgoing") ? "O" : statusList.Equals("Cancel") ? "C" : "D"); System.Diagnostics.Debug.WriteLine("Estado2: " + valStatus); System.Diagnostics.Debug.WriteLine("Entro"); todo myTodo = db.todos.Single(u => u.idTodo == todo.IdTodo); myTodo.nombre = todo.nameTodo; myTodo.descripcion = todo.descriptionTodo; myTodo.fechaI = todo.dateI; myTodo.fechaF = todo.dateF; myTodo.status = valStatus; try { db.SaveChanges(); } catch { ModelState.AddModelError("", "It can't edit this TO-DO"); return View(todo); } return RedirectToAction("MyToDo"); }
private IEnumerable<Examen3_Progra4.Models.todoEstructure> getTodos() { var values = from u in db.todos where u.userOwner.Equals(this.User.Identity.Name) orderby u.idTodo select u; List<Examen3_Progra4.Models.todoEstructure> results = new List<Examen3_Progra4.Models.todoEstructure>(); foreach(todo val in values){ Examen3_Progra4.Models.todoEstructure temp = new Examen3_Progra4.Models.todoEstructure { IdTodo=val.idTodo, nameTodo=val.nombre, descriptionTodo=val.descripcion, dateI=val.fechaI, dateF=val.fechaF, status=val.status, userOwner=val.userOwner }; results.Add(temp); } return results; }
public ActionResult Edit(int id = 0) { todo myTodo = db.todos.Single(u => u.idTodo == id); todoEstructure temp = new todoEstructure { IdTodo=myTodo.idTodo, nameTodo=myTodo.nombre, descriptionTodo=myTodo.descripcion, dateI=myTodo.fechaI, dateF=myTodo.fechaF, status=myTodo.status, userOwner=myTodo.userOwner }; string valStatus = (myTodo.status.Equals("O") ? "Outgoing" : myTodo.status.Equals("C") ? "Cancel" : "Done"); List<string> statusList=new List<string>(); statusList.Add(valStatus); if(!statusList.Contains("Outgoing")) statusList.Add("Outgoing"); if(!statusList.Contains("Cancel")) statusList.Add("Cancel"); if(!statusList.Contains("Done")) statusList.Add("Done"); ViewBag.statusList= new SelectList(statusList); return View(temp); }