在API中为ParentID添加和删除多个ChildID

时间:2019-06-08 14:58:04

标签: c# api asp.net-core-2.0

我创建了大家好,并且API一次创建和删除了一个子类别。 但我需要它也能够添加和删除多个子类别。

类似这样的东西:

For i = 1 To (mInlinShapes.Count) 'looping through my document inlineshapes
    If (mInlinShapes(i).Type = wdInlineShapePicture) Then
            Set Shp = mInlinShapes(i).ConvertToShape
            Shp.Select
            With Selection
                .InsertCaption Label:=wdCaptionFigure, _
                              Title:=" a custom title", _
                              Position:=wdCaptionPositionBelow, _
                              ExcludeLabel:=0

            End With

            With ActiveDocument.Styles("Caption").Font

                .Name = "Times New Roman"
                .Size = 18
                .ColorIndex = wdBrightGreen

            End With

            Shp.ConvertToInlineShape
    End If
Next i

我该怎么办?

这是示例表。

enter image description here

我每次在数据库中一次添加和删除一个,就像这样:

添加:

"CategoryParentID": "4",
"CategoryChildID": [
    {
      5,6,7,8
    }
  ],

删除:

 public async Task<ServiceResultWithoutBaseEntity<CategoryRollup>> Add(CategoryRollupViewModel newItem)
    {
        var result = new ServiceResultWithoutBaseEntity<CategoryRollup>();
        result.Errors.AddRange(Validate(newItem));

        if (result.HasErrors)
            return result;

        var item = newItem.MapToEntity(new CategoryRollup());

        _context.CategoryRollups.Add(item);
        await _context.SaveChangesAsync();

        result.EntityResult = item;

        return result;
    }

这是我的模型和视图模型:

enter image description here

0 个答案:

没有答案