Esempio n. 1
0
        public async Task <IActionResult> CreateTask([FromBody] Domain.Entities.Task task)
        {
            var validation = task.CheckTaskInformation();

            if (!validation.IsValid)
            {
                return(BadRequest(validation.Errors.Select(x => x.ErrorMessage)));
            }

            var wasCreated = await _taskApp.InsertTasks(task);

            if (wasCreated.Key)
            {
                return(Ok());
            }

            return(StatusCode(400, new { data = wasCreated.Value }));
        }
Esempio n. 2
0
        public async Task <IActionResult> UpdateTask(int id, [FromBody] Domain.Entities.Task task)
        {
            var validation = task.CheckTaskInformation();

            if (!validation.IsValid)
            {
                return(BadRequest(validation.Errors.Select(x => x.ErrorMessage)));
            }

            if (task.Id == 0)
            {
                task.Id = id;
            }

            var response = await _taskApp.UpdateTask(task);

            if (response.Key)
            {
                return(Ok());
            }

            return(StatusCode(400, new { data = response.Value }));
        }