Exemple #1
0
        public IEnumerable <ToDo> Get()
        {
            ToDoDAL     tododal = new ToDoDAL();
            List <ToDo> todos   = tododal.GetToDosAsGenericList();

            return(todos);
        }
Exemple #2
0
        public ToDo Get(int id)
        {
            ToDoDAL tododal = new ToDoDAL();
            ToDo    toDo    = tododal.ReadToDo(id);

            Console.WriteLine(toDo.Id);
            return(toDo);
        }
Exemple #3
0
 public ActionResult Update([FromBody] ToDo td)
 {
     try
     {
         ToDoDAL tddal = new ToDoDAL();
         tddal.updateToDo(td);
     }
     catch
     {
         return(BadRequest("something went wrong"));
     }
     return(Ok());
 }
Exemple #4
0
 public ActionResult Delete(int id)
 {
     try
     {
         ToDoDAL tddal = new ToDoDAL();
         tddal.DeleteToDo(id);
     }
     catch
     {
         return(BadRequest("somthing went wrong"));
     }
     return(Ok());
 }
Exemple #5
0
 public ActionResult Post(ToDo td)
 {
     try
     {
         ToDoDAL tddal = new ToDoDAL();
         tddal.InsertToDo(td);
     }
     catch
     {
         return(BadRequest("something went wrong"));
     }
     return(Ok());
 }
Exemple #6
0
        //public UserDAL TryLookUpUser(string emailAddress, string password)
        //{
        //    var listOfUsers = _toDoListContext.Users;
        //    foreach (var nUser in listOfUsers)
        //    {
        //        if (nUser.EmailAddress == emailAddress && nUser.Password == password)
        //        {
        //            return nUser;
        //        }
        //    };
        //    return new UserDAL();
        //}

        public IActionResult TryCreateItem(ToDo item, UserDashboardViewModel model)
        {
            var newItem = new ToDoDAL();

            newItem.Description = item.Description;
            newItem.DueDate     = item.DueDate;


            _toDoListContext.ToDoItems.Add(newItem);
            _toDoListContext.SaveChanges();

            model.ToDoItems = ConvertDALToBasic();

            return(View("UserDashboard", model));
        }