public ActionResult Edit(int id, FormCollection collection)
        {
            try
            {
                // TODO: Add update logic here
                var task = tasksService.Get(id);

                task.Content = collection["Content"];
                task.Date    = Convert.ToDateTime(collection["Date"]);
                if (collection["IsDone"].Equals("false"))
                {
                    task.IsDone = false;
                }
                else
                {
                    task.IsDone = true;
                }

                var newTask = tasksService.Add(task);

                return(Json(newTask, JsonRequestBehavior.AllowGet));
            }
            catch
            {
                return(Json("false", JsonRequestBehavior.AllowGet));
            }
        }
Beispiel #2
0
        // GET api/Default1/5
        public Task GetTodo(int id)
        {
            Task todo = tasksService.Get(id);

            if (todo == null)
            {
                throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.NotFound));
            }

            return(todo);
        }
Beispiel #3
0
        //
        public ActionResult MarkTaskAsDone(int id)
        {
            var task = tasksService.Get(id);

            if (task.IsDone == false)
            {
                task.IsDone = true;
            }
            else
            {
                task.IsDone = false;
            }

            tasksService.Add(task);

            return(RedirectToAction("Index"));
        }
Beispiel #4
0
 public ActionResult <IEnumerable <MyTask> > Get()
 {
     try
     {
         return(Ok(_ts.Get()));
     }
     catch (Exception err)
     {
         return(BadRequest(err.Message));
     }
 }
 public ActionResult <List <Task> > Get() => _tasksService.Get();