Exemplo n.º 1
0
        public async Task <ActionResult <Dtos.Task> > Create([FromBody] Dtos.Task dto)
        {
            var entity = new Entities.Task();

            TaskMapper.UpdateEntity(dto, entity);
            await _repository.SaveAsync(entity);

            dto = TaskMapper.ToDto(entity);
            return(CreatedAtAction(nameof(Get), new { id = dto.Id }, dto));
        }
Exemplo n.º 2
0
        public async Task <ActionResult> Update(Guid id, [FromBody] Dtos.Task dto)
        {
            var entity = await _repository.GetAsync(id);

            if (entity == null)
            {
                return(NotFound());
            }

            TaskMapper.UpdateEntity(dto, entity);
            await _repository.SaveAsync(entity);

            dto = TaskMapper.ToDto(entity);
            return(Ok());
        }