public void TestGetNextTaskId() { ToDoDB db = new ToDoDB(); int taskId = db.GetNextTaskId(); Assert.AreNotEqual(-1, taskId); }
public ActionResult DeleteConfirmed(int id) { ToDoDB tododb = db.ToDoDBlist.Find(id); db.ToDoDBlist.Remove(tododb); db.SaveChanges(); return(RedirectToAction("Index")); }
public void TestCheckTaskExistsInDB() { ToDoDB db = new ToDoDB(); int value = db.InsertDisposableTask(new DisposableTask()); Debug.WriteLine("value is: " + value); Assert.IsTrue(db.CheckTaskExistsInDB(value)); Assert.IsFalse(db.CheckTaskExistsInDB(-1)); }
public void TestInsertDisposableTask() { ToDoDB db = new ToDoDB(); int nextId = db.GetNextTaskId() + 1; Dictionary <int, SubTask> dictionary = new Dictionary <int, SubTask>(); DisposableTask dTask = new DisposableTask("Title", "This is a description", dictionary); int actualId = db.InsertDisposableTask(dTask); Assert.IsTrue(db.CheckTaskExistsInDB(nextId)); }
public JsonResult DeleteToDo(int _todoId) { try { var result = ToDoDB.GetInstance().DeleteToDo(_todoId); return(Json(result)); } catch (System.Exception exc) { throw exc; } }
// GET: /List/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ToDoDB tododb = db.ToDoDBlist.Find(id); if (tododb == null) { return(HttpNotFound()); } return(View(tododb)); }
public ActionResult Create([Bind(Include = "ID,Title,Description,checkList")] ToDoDB tododb) { if (ModelState.IsValid) { string currentUserId = User.Identity.GetUserId(); ApplicationUser currentUser = db.Users.FirstOrDefault(user => user.Id == currentUserId); tododb.User = currentUser; db.ToDoDBlist.Add(tododb); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(tododb)); }
public JsonResult GetToDoById(int _todoId) { try { using (var context = new ProjectManagementEntities()) { var list = ToDoDB.GetInstance().GetToDoById(_todoId).ToList(); return(Json(list)); } } catch (System.Exception exc) { throw exc; } }
public TodoListViewModel() { ToDoDB _context = new ToDoDB(); Items = new ObservableCollection <ToDoItem>(_context.GetAllItems()); // Demo Api Call Task getAllLecturesTask = MyHTTP.GetWebApiItems(x => { foreach (var item in x) { Items.Add(item); } }); }
public TodoCreateEditViewModel(int id) { if (id == 0) { Title = ""; Content = ""; } else { ToDoDB _context = new ToDoDB(); var todoItem = _context.GetItemByID(id); Title = todoItem.Title; Content = todoItem.Content; ItemId = id; } }
public ActionResult ClickEdit(int?id, bool value) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ToDoDB tododb = db.ToDoDBlist.Find(id); if (tododb == null) { return(HttpNotFound()); } else { tododb.checkList = value; db.Entry(tododb).State = EntityState.Modified; db.SaveChanges(); } return(PartialView("_ListControll", GetList())); }
public void TestUpdateTask() { ToDoDB db = new ToDoDB(); int taskId = db.GetNextTaskId() + 1; Dictionary <int, SubTask> dictionary = new Dictionary <int, SubTask>(); DisposableTask expectedTask = new DisposableTask(); expectedTask.setTaskId(taskId); //Id expectedTask.setTitle("TestTitle"); //Title expectedTask.setDescription("TestDescription"); //Notes expectedTask.setAllowNotifications(false); //allowNotifications expectedTask.setIsComplete(false); //isComplete expectedTask.setTaskFKey(0); //taskFKey db.InsertDisposableTask(expectedTask); expectedTask.setTitle("UPDATEDTITLE"); //Title db.UpdateTask(expectedTask); DisposableTask actualTask = db.FetchDisposableTask(taskId + 1); //expectedTask.setTaskId(taskId); Assert.AreEqual(expectedTask, actualTask); }
public ActionResult Edit([Bind(Include = "ID,Title,Description,checkList")] ToDoDB tododb) { if (ModelState.IsValid) { //bugging losting FK when save //db.Entry(tododb).State = EntityState.Modified; var dbModel = db.ToDoDBlist.Where(x => x.ID == tododb.ID).FirstOrDefault(); if (dbModel == null) { return(HttpNotFound()); } else { dbModel.checkList = tododb.checkList; dbModel.Title = tododb.Title; dbModel.Description = tododb.Description; db.SaveChanges(); } db.SaveChanges(); return(RedirectToAction("Index")); } return(View(tododb)); }
public JsonResult SaveToDo(string _todoName, string _todoEndDate, int _projectId, List <int> _todoUsers) { try { var _personId = JsonConvert.DeserializeObject <Project>(HttpContext.Session.GetString("ActivePerson")).Id; _todoUsers.Add(_personId); _todoUsers = _todoUsers.Distinct().ToList(); var todo = new ToDo() { Detail = _todoName, ProjectId = _projectId, EndDate = DateTime.ParseExact(_todoEndDate, "dd/MM/yyyy", null), Status = 1 }; var result = ToDoDB.GetInstance().SaveToDo(todo); foreach (var item in _todoUsers) { var todouser = new ToDoUser() { ToDoId = result.Id, PersonId = item }; ToDoUserDB.GetInstance().SaveToDoUser(todouser); } return(Json(result != null)); } catch (System.Exception exc) { throw exc; } }
public JsonResult UpdateToDo(string _todoName, string _todoEndDate, int _todoId, int _projectId, List <int> _todoUsers) { try { var _personId = JsonConvert.DeserializeObject <Project>(HttpContext.Session.GetString("ActivePerson")).Id; _todoUsers.Add(_personId); _todoUsers = _todoUsers.Distinct().ToList(); var todolist = new ToDo() { Detail = _todoName, EndDate = DateTime.ParseExact(_todoEndDate, "dd/MM/yyyy", null), Id = _todoId, Status = 1, ProjectId = _projectId }; var result = ToDoDB.GetInstance().UpdateToDo(todolist, _todoUsers); return(Json(result != null)); } catch (System.Exception exc) { throw exc; } }