Skip to content

Commit 2343c41

Browse files
committed
feat: add ordering column to objectives
1 parent e4dafb4 commit 2343c41

12 files changed

Lines changed: 3750 additions & 1 deletion

PrismaDotnetApi/PrismaApi.Application/Mapping/ObjectiveMappingExtensions.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ public static ObjectiveOutgoingDto ToOutgoingDto(this Objective entity)
1616
Name = entity.Name,
1717
Type = entity.Type,
1818
Description = entity.Description,
19+
Ordering = entity.Ordering,
1920
CreatedAt = entity.CreatedAt,
2021
UpdatedAt = entity.UpdatedAt
2122
};
@@ -35,6 +36,7 @@ public static Objective ToEntity(this ObjectiveIncomingDto dto, UserOutgoingDto
3536
Name = dto.Name,
3637
Type = dto.Type,
3738
Description = dto.Description,
39+
Ordering = dto.Ordering,
3840
CreatedById = userDto.Id,
3941
UpdatedById = userDto.Id,
4042
};
@@ -49,6 +51,7 @@ public static Objective ToEntity(this ObjectiveViaProjectDto dto, Guid projectId
4951
Name = dto.Name,
5052
Type = dto.Type,
5153
Description = dto.Description,
54+
Ordering = dto.Ordering,
5255
CreatedById = userDto.Id,
5356
UpdatedById = userDto.Id,
5457
};

PrismaDotnetApi/PrismaApi.Application/Repositories/EntitiesExtensions.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ public static void Update(this ICollection<Objective> entities, ICollection<Obje
4848
entity.Type = incomingEntity.Type;
4949
entity.ProjectId = incomingEntity.ProjectId;
5050
entity.Description = incomingEntity.Description;
51+
entity.Ordering = incomingEntity.Ordering;
5152
entity.UpdatedById = incomingEntity.UpdatedById;
5253
}
5354
}

PrismaDotnetApi/PrismaApi.Application/Services/ProjectduplicationService.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,7 @@ private static List<ObjectiveIncomingDto> CreateObjectives(IEnumerable<Objective
475475
Name = o.Name,
476476
Description = o.Description,
477477
Type = o.Type,
478+
Ordering = o.Ordering,
478479
ProjectId = newProjectId
479480
}).ToList();
480481
}
@@ -487,6 +488,7 @@ private static List<ObjectiveIncomingDto> CreateObjectives(IEnumerable<Objective
487488
Name = o.Name,
488489
Description = o.Description,
489490
Type = o.Type,
491+
Ordering = o.Ordering,
490492
ProjectId = newProjectId
491493
}).ToList();
492494
}

PrismaDotnetApi/PrismaApi.Domain/Dtos/ObjectiveDtos.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ public class ObjectiveDto
1111
public string Name { get; set; } = string.Empty;
1212
[JsonPropertyName("description")]
1313
public string Description { get; set; } = string.Empty;
14+
[JsonPropertyName("ordering")]
15+
public int Ordering { get; set; }
1416
}
1517

1618
public class ObjectiveViaProjectDto : ObjectiveDto

PrismaDotnetApi/PrismaApi.Domain/Entities/Objective.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ public class Objective : AuditableEntity, IBaseEntity<Guid>
1111
public string Name { get; set; } = string.Empty;
1212
public string Type { get; set; } = string.Empty;
1313
public string Description { get; set; } = string.Empty;
14+
public int Ordering { get; set; }
1415
public Project? Project { get; set; }
1516
public static void OnModelConfiguring(ModelBuilder modelBuilder)
1617
{

PrismaDotnetApi/PrismaApi.Test/ControllerTests/ObjectivesControllerTests.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,14 +99,21 @@ public async Task UpdateObjectives_UpdatesObjectives()
9999
ProjectId = projectId,
100100
Name = updatedName,
101101
Description = "Objective A description",
102+
Ordering = 7,
102103
Type = ObjectiveType.Fundamental.ToString()
103104
}
104105
};
105106

106107
var updateResponse = await Client.TestClientPutAsync<List<ObjectiveOutgoingDto>>("objectives", updatePayload);
107108

108109
Assert.Equal(HttpStatusCode.OK, updateResponse.Response.StatusCode);
109-
Assert.Contains(updateResponse.Value, objective => objective.Id == objectiveId && objective.Name == updatedName);
110+
Assert.Contains(updateResponse.Value, objective =>
111+
objective.Id == objectiveId && objective.Name == updatedName && objective.Ordering == 7);
112+
113+
var getUpdatedResponse = await Client.TestClientGetAsync<ObjectiveOutgoingDto>($"objectives/{objectiveId}");
114+
115+
Assert.Equal(HttpStatusCode.OK, getUpdatedResponse.Response.StatusCode);
116+
Assert.Equal(7, getUpdatedResponse.Value.Ordering);
110117
}
111118

112119
[Fact]

0 commit comments

Comments
 (0)