本文整理汇总了C#中ITaskService.AddTaskItem方法的典型用法代码示例。如果您正苦于以下问题:C# ITaskService.AddTaskItem方法的具体用法?C# ITaskService.AddTaskItem怎么用?C# ITaskService.AddTaskItem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ITaskService
的用法示例。
在下文中一共展示了ITaskService.AddTaskItem方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TasksApiModule
public TasksApiModule(ITaskService taskService)
: base("/api")
{
Get["/tasks"] = parameters =>
{
var tasks =
taskService.FindTaskItemsByName(new FindTaskItemsByNameRequest()
{Query = "", RequestUserId = 1}).TaskItems;
var response =
new JsonResponse(tasks.Select(t =>
new TaskViewModel()
{
TaskItemId = t.TaskItemId,
Title = t.Title,
Details = t.Details,
AssignedToUserId =
t.AssignedToUserId > 0
? (int?) t.AssignedToUserId
: null,
Comments = t.Comments.Select(c => new CommentViewModel()
{
TaskItemId = t.TaskItemId,
CommentId = c.CommentId,
CreatedByUserId = c.CreatedByUserId,
Comment = c.Comment
})
})
).WithNoCache();
return response;
};
Post["/tasks"] = parameters =>
{
var taskViewModel = this.Bind<TaskViewModel>();
var taskId = taskViewModel.TaskItemId.GetValueOrDefault(0);
if (taskId == 0)
{
var response = taskService.AddTaskItem(new AddTaskItemRequest()
{
Title = taskViewModel.Title,
Details = taskViewModel.Details,
RequestUserId = int.Parse(Context.Request.Headers["TM-RequestUserId"].First()),
AssignedToUserId = taskViewModel.AssignedToUserId
});
return new JsonResponse(response.TaskItemId);
}
else
{
var response = taskService.EditTaskItem(new EditTaskItemRequest()
{
TaskItemId = taskId,
Title = taskViewModel.Title,
Details = taskViewModel.Details,
AssignedToUserId = taskViewModel.AssignedToUserId
});
return new JsonResponse(response.TaskItemId);
}
};
Post["/tasks/comments"] = parameters =>
{
var commentViewModel = this.Bind<CommentViewModel>();
var commentId = commentViewModel.CommentId.GetValueOrDefault(0);
if (commentId == 0)
return new JsonResponse("Unknown Task");
var createdById =
int.Parse(Context.Request.Headers["TM-RequestUserId"].First());
var response = taskService.AddComment(new AddCommentRequest() { Comment = commentViewModel.Comment, TaskItemId = commentViewModel.TaskItemId, RequestUserId = createdById });
return new JsonResponse(response.CommentId);
};
}