Example #1
0
        public IHttpActionResult UpdateTask(Todo.Models.Task task)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            try
            {
                taskService.AddOrUpdate(task);
                taskService.Save();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }

            return(Ok(task));
        }
Example #2
0
        public IHttpActionResult InsertTask(Todo.Models.Task task)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            task.UserId    = User.Identity.GetUserId();
            task.DateAdded = DateTime.Now;

            try
            {
                taskService.AddOrUpdate(task);
                taskService.Save();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }


            return(Ok(task));
        }