public async Task UpdateDataCategoryOrderCommandHandlerTest() { int dataCategoryId = 63; int personId = 13; string userId = "e57c56b8-9fe2-4a64-8b3f-b4c90174b2b1"; var command = new UpdateDataCategoryOrderCommand() { Id = dataCategoryId, Order = 6, UserId = userId }; int[] expected = { 61, 62, 64, 65, 77, 63, 78 }; int[] actual = null; using (var scope = _serviceProvider.CreateScope()) { var sender = scope.ServiceProvider.GetRequiredService <ISender>(); var result = await sender.Send(command); var context = scope.ServiceProvider.GetRequiredService <IApplicationDbContext>(); actual = context.DataCategories .Where(dc => dc.PersonId == personId) .OrderBy(dc => dc.OrderNumber) .Select(dc => dc.Id) .ToArray(); } CollectionAssert.AreEqual(expected, actual); }
public async Task <ActionResult> UpdateOrder(int id, UpdateDataCategoryOrderCommand command) { if (id != command.Id) { return(BadRequest()); } command.UserId = _currentUserService.UserId; await Mediator.Send(command); return(NoContent()); }