public static ApiGeoTask ToApiGeoTask(this GeoTask from) { if (from is null) { return(null); } var to = new ApiGeoTask { Description = from.Description, Id = from.Id, PlanFinishAt = from.PlanFinishAt, PlanStartAt = from.PlanStartAt, ProjectId = from.ProjectId, ResponsibleActor = from.ResponsibleActor.ToApiActor(), Title = from.Title, CreatedAt = from.CreatedAt, CreatedBy = from.CreatedBy.ToApiActor(), IsArchived = from.IsArchived, Status = from.Status, StatusChangedAt = from.StatusChangedAt }; to.AssistentActors.AddRange(from.AssistentActors.Select(x => x.ToApiActor())); to.GeosIds.AddRange(from.GeosIds); to.History.AddRange(from.History.Select(x => x.ToApiGeoTaskHistory())); to.ObserverActors.AddRange(from.ObserverActors.Select(x => x.ToApiActor())); return(to); }
public static GeoTaskUpdateCommand ToGeoTaskUpdateCommand (this ApiGeoTask from, string id, ClaimsPrincipal currentPrincipal, string messageTitle, string messageDescription) { if (from is null) { return(null); } var to = new GeoTaskUpdateCommand { Description = from.Description, Id = id, PlanFinishAt = from.PlanFinishAt, PlanStartAt = from.PlanStartAt, ProjectId = from.ProjectId, ResponsibleActorId = from.ResponsibleActor?.Id, Title = from.Title, CurrentPrincipal = currentPrincipal, IsArchived = from.IsArchived, Status = from.Status, MessageDescription = messageDescription, MessageTitle = messageTitle }; to.AssistentActorsIds .AddRange(from.AssistentActors.Select(x => x.Id)); to.GeosIds.AddRange(from.GeosIds); to.ObserverActorsIds .AddRange(from.ObserverActors.Select(x => x.Id)); return(to); }
public async Task GetIdReturnsOkResultWhenSuccessAnswerAsync() { // Arrange var entityId = "0000000000000000"; var appEntity = new GeoTask() { Id = entityId, IsArchived = false, Title = "Test GeoTask" }; var apiEntity = new ApiGeoTask() { Id = entityId, IsArchived = false, Title = "Test GeoTask" }; var mediator = new Mock <IMediator>(); mediator.Setup(x => x.Send(It.IsAny <EntityQuery <GeoTask> >(), It.IsAny <CancellationToken>())) .ReturnsAsync( new EntityResponse <GeoTask>() { Success = true, Entity = appEntity }) .Verifiable("Query was not sent."); var controller = BuildController(mediator); // Act var controllerAnswer = await controller.Get(entityId); // Assert Assert.IsType <OkObjectResult>(controllerAnswer); Assert.Equal(apiEntity.Id, (((OkObjectResult)controllerAnswer).Value as ApiGeoTask).Id); mediator.Verify(x => x.Send(It.IsAny <EntityQuery <GeoTask> >(), It.IsAny <CancellationToken>())); }