Exemple #1
0
        public override async Task <Response> Handle(Request request, CancellationToken cancellationToken)
        {
            var assignee = request.AssignTo?.Value != null
                                ? await this.context.Users.FindOrExceptionAsync(request.AssignTo.Value.Value)
                                : null;

            var creator = await this.context.Users.FindOrExceptionAsync(this.userSession.CurrentUserId);

            var item = new WorkItem(request.Description?.Value, creator);

            item.AssignToUser(assignee);

            this.context.WorkItems.Add(item);
            await this.context.SaveChangesAsync(cancellationToken);

            return(new Response
            {
                Id = item.Id,
                Form = typeof(WorkItemOverview).GetFormId(),
                InputFieldValues = new Dictionary <string, object>
                {
                    { nameof(WorkItemOverview.Request.Id), item.Id }
                }
            });
        }