Пример #1
0
        public ActionResult <Models.TodoTask> Insert(Models.TodoTask todoTask)
        {
            int id = liteDbTodoTaskService.InsertTodoTask(todoTask);

            if (id != default)
            {
                return(CreatedAtAction("GetTodoTask", liteDbTodoTaskService.GetTodoTask(id)));
            }
            else
            {
                return(BadRequest());
            }
        }
Пример #2
0
        public ActionResult <Models.TodoTask> Update(Models.TodoTask todoTask)
        {
            bool result = liteDbTodoTaskService.UpdateTodoTask(todoTask);

            if (result)
            {
                return(NoContent());
            }
            else
            {
                return(NotFound());
            }
        }
Пример #3
0
        public ActionResult <Models.TodoTask> Get(int id)
        {
            Models.TodoTask todoTask = liteDbTodoTaskService.GetTodoTask(id);

            if (todoTask != default)
            {
                return(Ok(todoTask));
            }
            else
            {
                return(NotFound());
            }
        }
Пример #4
0
        bool ITodoTaskService.UpdateTodoTask(Models.TodoTask todoTask)
        {
            using (MySqlConnection connection = new MySqlConnection(DbContext.ConnectionString))
            {
                connection.Open();
                using (MySqlCommand command = new MySqlCommand(SQL_UPDATE, connection))
                {
                    command.Parameters.AddWithValue("@title", todoTask.Title);
                    command.Parameters.AddWithValue("@description", todoTask.Description);
                    command.Parameters.AddWithValue("@location", todoTask.Location);
                    command.Parameters.AddWithValue("@addeddate", todoTask.AddedDate);
                    command.Parameters.AddWithValue("@id", todoTask.Id);

                    return(command.ExecuteNonQuery() > 0 ? true : false);
                }
            }
        }