public async Task <IActionResult> Post([FromBody] Todo todo) { todo.CreatedByUserId = GetuserId(); //todo.CreatedByTimestamp = DateTime.UtcNow; await _todos.CreateTodo(todo); return(Ok("complete")); }
public async Task <IActionResult> CreateTodo(TodoCreateRequest request) { if (!ModelState.IsValid) { return(StatusCode(400)); } var dto = _mapper.Map <TodoCreateDTO>(request); dto.CreatedOn = DateTime.Now; dto.IsCompleted = false; if (await _manager.CreateTodo(dto)) { return(StatusCode(201)); } throw new Exception(); }