Exemplo n.º 1
0
        public async Task <IActionResult> UpdateProject([FromBody] SubtaskDTO subtaskToUpdate)
        {
            try
            {
                var modelToUpdate = mapper.Map <SubtaskDTO, Subtask>(subtaskToUpdate);
                await subtaskService.Update(modelToUpdate);

                return(Ok());
            }
            catch (CustomException e)
            {
                return(e.GetActionResult());
            }
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Post([FromBody] SubtaskDTO subtaskToAdd)
        {
            try
            {
                var subtask = mapper.Map <SubtaskDTO, Subtask>(subtaskToAdd);
                subtask.SubtaskId = 0;
                var savedSubtask = await subtaskService.AddAsync(subtask);

                var dto = mapper.Map <Subtask, SubtaskDTO>(savedSubtask);
                return(Ok(dto));
            }
            catch (CustomException e)
            {
                return(e.GetActionResult());
            }
        }