Exemplo n.º 1
0
        public async Task <IActionResult> Create([FromBody] JObject task)
        {
            var userId      = GetUserId();
            var taskId      = task["TaskId"].ToObject <Guid>();
            var description = task["Description"].ToObject <string>();

            await _toDoListService.CreateTask(new CreateNewToDoTask()
            {
                UserId      = userId,
                TaskId      = taskId,
                Description = description
            });

            var createdTask = await _toDoListService.GetById(userId, taskId);

            var createdTaskViewModel = new ToDoTaskViewModel()
            {
                Id = createdTask.Id,
                ModificationDateTimeOffset = createdTask.ModificationDateTimeOffset,
                CreationDateTimeOffset     = createdTask.CreationDateTimeOffset,
                IsChecked   = createdTask.IsChecked,
                Description = createdTask.Description
            };

            return(PartialView("_TodoTaskViewModel", createdTaskViewModel));
        }