コード例 #1
0
        public void SetUp()
        {
            report  = new Report();
            request = new MoveReportAssignmentRequest
            {
                ReportId = "xxx", NewAssigneeId = 0
            };

            reportManager       = new Mock <IReportManager>();
            reportValidationHub = new Mock <IReportValidationHub>();
            httpContextReader   = new Mock <IHttpContextReader>();
            var notifier   = new Mock <INotifier>();
            var hubManager = new Mock <IHubManager <NotifierHub> >();
            var mapper     = new Mock <IMapper>();

            reportManager.Setup(rm => rm.MoveReportAssignment(It.IsAny <Report>(), It.IsAny <int>()))
            .ReturnsAsync(true);
            reportManager
            .Setup(rm => rm.GetReportsAllowedAssignees((ReportCategoryType)report.CategoryType, report.Private))
            .ReturnsAsync(new List <User>
            {
                new User()
            });
            reportValidationHub.Setup(rv =>
                                      rv.ValidateAndReturnReport(It.IsAny <string>(), It.IsAny <ReportPermission[]>()))
            .ReturnsAsync(report);
            httpContextReader.Setup(h => h.CurrentUserId).Returns(1);

            moveReportAssignmentCommand =
                new MoveReportAssignmentCommand(reportManager.Object, reportValidationHub.Object,
                                                httpContextReader.Object, notifier.Object, hubManager.Object, mapper.Object);
        }
コード例 #2
0
        public async Task <IActionResult> MoveReportAssignment(MoveReportAssignmentRequest request)
        {
            var response = await mediator.Send(request);

            Log.Information(
                $"User #{HttpContext.GetCurrentUserId()} moved report #{request.ReportId} assignment to user #{request.NewAssigneeId}");

            return(this.CreateResponse(response));
        }