Controller: IModelEntryExampleController.cs
using Microsoft.AspNetCore.Mvc;
using Appeon.ApiDoc.Models.School;
using SnapObjects.Data;
using System.Linq;
namespace Appeon.ApiDoc.IModelEntryExamples
{
[Route("examples/IModelEntry/[action]")]
public class IModelEntryExampleController : Controller
{
SchoolContext _dataContext;
public IModelEntryExampleController(SchoolContext dataContext)
{
// Sets the data context.
_dataContext = dataContext;
}
[HttpPost]
public string Example(IDataUnpacker dataUnpacker)
{
// Uses IDataUnpack to receive JSON data from the client app.
var student =
dataUnpacker.GetModelEntries<Person>("student").FirstOrDefault();
var example = new IModelEntryExample(_dataContext);
example.Example(student);
return "SUCCESS";
}
}
}
Refer To
JSON File: Example