Exemplo n.º 1
0
        public IActionResult Post([FromBody] TaskWork taskWorkNew)
        {
            if (taskWorkNew.IsObjectNull())
            {
                return(BadRequest(new { Message = "DeathDate object is null" }));
            }
            if (!ModelState.IsValid)
            {
                return(BadRequest(new { Message = "Invalid model object" }));
            }
            try
            {
                this.taskWorkBR.CreateTask(taskWorkNew);
                if (taskWorkNew.IsEmptyObject())
                {
                    return(BadRequest(new { Message = "Task Object is not Created" }));
                }

                return(CreatedAtRoute("TaskWorkById", new { id = taskWorkNew.Id }, taskWorkNew));
            }
            catch (Exception ex)
            {
                return(StatusCode(500, new { Message = $"Internal server error: {ex.Message}" }));
            }
        }