Skip to content

Commit e06d21e

Browse files
committed
MMI-3272 Fix merge series
1 parent 791f83e commit e06d21e

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

api/net/Areas/Admin/Controllers/SeriesController.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -129,22 +129,22 @@ public IActionResult Update([FromBody] SeriesModel model)
129129
/// <summary>
130130
/// Merge two series records..
131131
/// </summary>
132-
/// <param name="id">the master series record</param>
133-
/// <param name="fromId">the record to be merged into the master</param>
132+
/// <param name="intoId">the record to be merged into the master</param>
133+
/// <param name="fromId">the master series record</param>
134134
/// <returns></returns>
135-
[HttpPut("{id}/merge/{fromId}")]
135+
[HttpPut("{intoId}/merge/{fromId}")]
136136
[Produces(MediaTypeNames.Application.Json)]
137137
[ProducesResponseType(typeof(SeriesModel), (int)HttpStatusCode.OK)]
138138
[ProducesResponseType(typeof(ErrorResponseModel), (int)HttpStatusCode.BadRequest)]
139139
[SwaggerOperation(Tags = new[] { "Series" })]
140-
public IActionResult Merge(int id, int fromId)
140+
public IActionResult Merge(int fromId, int intoId)
141141
{
142142
// make sure the merge target exists
143-
var _ = _service.FindById(id) ?? throw new NoContentException();
143+
var _ = _service.FindById(fromId) ?? throw new NoContentException();
144144
// make sure the merge source exists
145-
_ = _service.FindById(fromId) ?? throw new NoContentException();
145+
_ = _service.FindById(intoId) ?? throw new NoContentException();
146146
// merge the source into the target
147-
var result = _service.Merge(id, fromId) ?? throw new NoContentException();
147+
var result = _service.Merge(fromId, intoId) ?? throw new NoContentException();
148148
return new JsonResult(new SeriesModel(result));
149149
}
150150

app/editor/src/features/admin/series/SeriesMerge.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ const SeriesMerge: React.FC = () => {
7171
Show/Program and then click the [Merge] button.
7272
</p>
7373
<p>
74-
Any content which is asociated with the merged Show/Program, will be re-associated
74+
Any content which is associated with the merged Show/Program, will be re-associated
7575
with the current Show/Program.
7676
</p>
7777
<Row>
@@ -108,7 +108,7 @@ const SeriesMerge: React.FC = () => {
108108
confirmText="Yes, merge them"
109109
onConfirm={async () => {
110110
try {
111-
await api.mergeSeries(targetSeriesId, Number(mergeSeriesSourceOption?.value));
111+
await api.mergeSeries(Number(mergeSeriesSourceOption?.value), targetSeriesId);
112112
setMergeSeriesSourceOption(undefined);
113113
toast.success(`Series/Program merge completed successfully.`);
114114
} finally {

libs/net/dal/Services/SeriesService.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,12 +139,12 @@ public override Series UpdateAndSave(Series entity)
139139
return base.UpdateAndSave(original);
140140
}
141141

142-
public Series? Merge(int intoId, int fromId)
142+
public Series? Merge(int fromId, int intoId)
143143
{
144144
// get a list of content ids by finding all content records which refer to the fromId
145145
var contentIdsToUpdate = this.Context.Contents.Where((c) => c.SeriesId == fromId).Select((c) => c.Id).ToList();
146146
// if there are in fact records to update, update them
147-
if (contentIdsToUpdate.Any())
147+
if (contentIdsToUpdate.Count != 0)
148148
{
149149
this.Context.Contents
150150
.Where(f => contentIdsToUpdate.Contains(f.Id))

0 commit comments

Comments
 (0)