Esempio n. 1
0
        public int?CreateTask(int userId, TaskModelColumnLink task)
        {
            using IDbConnection db = new SqlConnection(_connectionString);
            Debug.Assert(task.ColumnId != null, "task.ColumnId != null");
            if (!ColumnRepository.IsAllowed(db, userId, (int)task.ColumnId))
            {
                return(null);
            }

            return(db.Query <int?>(@"INSERT INTO TaskTable(Name, Description, ColumnId, Position) 
                OUTPUT INSERTED.Id VALUES
                (@taskName, @taskDescription, @columnId, @position);",
                                   new { taskName = task.Name, taskDescription = task.Description, columnId = task.ColumnId, position = GetTasksCount(db, (int)task.ColumnId) }).FirstOrDefault());
        }
Esempio n. 2
0
        public ActionResult CreateTask(TaskModelColumnLink task)
        {
            int?userId;

            if ((userId = AuthHelper.GetUserId(HttpContext)) == null)
            {
                return(Unauthorized());
            }

            int?taskId = _taskRepository.CreateTask((int)userId, task);

            if (taskId == null)
            {
                return(StatusCode(403));
            }

            return(Ok(new { id = taskId }));
        }