Example #1
0
        public IActionResult Post([FromBody]TaskModel newTask)
        {
            var addTaskCommand = new AddTaskCommand(
               taskName: newTask.TaskName,
               taskDescription: newTask.TaskDescription,
               dueDate: DateTime.Parse(newTask.DueDate)
               );

            _commandProcessor.Send(addTaskCommand);

            return this.CreatedAtRoute("GetTask", new {id = addTaskCommand.TaskId}, null);
        }
        public OperationResult Post(TaskModel newTask)
        {
            var addTaskCommand = new AddTaskCommand(
                taskName: newTask.TaskName,
                taskDescription: newTask.TaskDescription,
                dueDate: DateTime.Parse(newTask.DueDate)
                );

            _commandProcessor.Send(addTaskCommand);

            return new OperationResult.Created
            {
                RedirectLocation = new Uri(string.Format("{0}/tasks/{1}", _communicationContext.ApplicationBaseUri, addTaskCommand.TaskId))
            };
        }
        public OperationResult Post(TaskModel newTask)
        {
            var addTaskCommand = new AddTaskCommand(
                taskName: newTask.TaskName,
                taskDecription: newTask.TaskDescription,
                dueDate: DateTime.Parse(newTask.DueDate)
                );

            commandProcessor.Send(addTaskCommand);

            return new OperationResult.Created
                {
                    ResponseResource = taskRetriever.Get(addTaskCommand.TaskId),
                    CreatedResourceUrl = new Uri(string.Format("{0}/tasks/{1}", communicationContext.ApplicationBaseUri, addTaskCommand.TaskId))
                };
        }