// 關閉資料庫連線 protected override void Dispose(bool disposing) { ToDoDBContext _db = _ToDoOperation.GetDBContext(); _db.Dispose(); base.Dispose(disposing); }
public IActionResult Index() { using (var db = new ToDoDBContext()) { var allTasks = db.Tasks.ToList(); return(View(allTasks)); } }
public ToDo Post(ToDo todo) { var cx = new ToDoDBContext(); var curr = cx.ToDoes.Single(e => e.id == todo.id); curr.updated = DateTime.Now; curr.category = todo.category; curr.comment = todo.comment; cx.SaveChanges(); return(todo); }
public ToDo Post(ToDo todo) { var cx = new ToDoDBContext(); todo.id = Guid.NewGuid(); todo.created = DateTime.Now; todo.updated = DateTime.Now; cx.ToDoes.Add(todo); cx.SaveChanges(); return(todo); }
public IActionResult Delete(int id) { using (var db = new ToDoDBContext()) { var taskToDelete = db.Tasks.First(t => t.Id == id); db.Tasks.Remove(taskToDelete); db.SaveChanges(); } return(RedirectToAction("Index")); }
public ToDoController(ToDoDBContext context) { _context = context; if (_context.ToDoItems.Count() == 0) { _context.ToDoItems.Add(new ToDoItem { Name = "Item1" }); _context.SaveChanges(); } }
public IActionResult Edit(int id) { using (var db = new ToDoDBContext()) { var taskToEdit = db.Tasks.FirstOrDefault(t => t.Id == id); if (taskToEdit == null) { return(RedirectToAction("Index")); } return(this.View(taskToEdit)); } }
public IActionResult Details(int id) { using (var db = new ToDoDBContext()) { Task taskDetails = db.Tasks.FirstOrDefault(t => t.Id == id); if (taskDetails == null) { return(RedirectToAction("Index")); } return(View(taskDetails)); } }
public ActionResult Detail(int id) { ToDo model; if (id == 0) { model = new ToDo(); } else { model = new ToDoDBContext().ToDoes.Single(e => e.Id == id); } return(View(model)); }
public IActionResult Create(Task taskToCreate) { if (ModelState.IsValid) { using (var db = new ToDoDBContext()) { db.Tasks.Add(taskToCreate); db.SaveChanges(); } } else { TempData["ErrorMessage"] = "Fill up all the fields of the form!"; return(this.View()); } return(RedirectToAction("Index")); }
public IActionResult Edit(Task editedTask) { if (ModelState.IsValid) { using (var db = new ToDoDBContext()) { var taskToEdit = db.Tasks.First(t => t.Id == editedTask.Id); taskToEdit.Title = editedTask.Title; taskToEdit.Comments = editedTask.Comments; db.SaveChanges(); return(RedirectToAction("Index")); } } return(RedirectToAction("Index")); }
public async System.Threading.Tasks.Task <ActionResult> Detail(int id, ToDo model, FormCollection formcol) { if (formcol["Save"] == "Save") { var cx = new ToDoDBContext(); if (id == 0) { model.GId = Guid.NewGuid(); model.Created = DateTime.Now; cx.ToDoes.Add(model); cx.SaveChanges(); //Send to sservice bus ServiceBusHelper.SendToAll(model); } else { var p = cx.ToDoes.Single(e => e.Id == id); p.Note = model.Note; p.Category = model.Category; cx.SaveChanges(); } } else if (formcol["Comment"] == "Comment") { if (formcol["CommentText"].Length > 0) { var td = new ToDoComment(); td.Id = Guid.NewGuid(); td.ToDoGId = model.GId; td.Created = DateTime.Now; td.Comment = formcol["CommentText"]; var doc = new DocDBContext(); await doc.InsertComment(td); return(RedirectToAction("Detail", new { id = id })); } } return(RedirectToAction("Index")); }
public EmailService(IConfiguration iConfiguration, ToDoDBContext _context) { _iConfiguration = iConfiguration; this._context = _context; }
public ToDoListController(ToDoDBContext context) { _context = context; }
public ToDoCategoriasController(ToDoDBContext context) { _context = context; }
public ToDoUsersController(ToDoDBContext context) { _context = context; }
public ToDoController(ToDoDBContext context) { _toDoDB = context; }
public TasksService(ToDoDBContext _context) { this._context = _context; }
public HomeController(ToDoDBContext context) { _context = context; }
public TasksController(ToDoDBContext context) { _context = context; }
public SubTaskRepository(ToDoDBContext context) { _context = context; }
public ToDoRepository(ToDoDBContext context) { _context = context; }
public UnitOfWork(ToDoDBContext context) { Context = context; }
public LoginService(ToDoDBContext _context) { this._context = _context; }
public DataRepository(ToDoDBContext context) { this.Context = context; }
public ToDoItemsController(ToDoDBContext context) { _context = context; }
public ToDoService(ToDoDBContext dbContext) { _dbContext = dbContext; }
public UnitOfWork() { _context = new ToDoDBContext(); DataRepo = new DataRepository(_context); }
public UserRepository(ToDoDBContext context) { _context = context; }