Controller: TrackExampleController.cs
using Microsoft.AspNetCore.Mvc;
using Appeon.ApiDoc.Models.School;
using SnapObjects.Data;
using System.Linq;
namespace Appeon.ApiDoc.ISqlModelMapperExamples.Controllers
{
[Route("examples/ISqlModelMapper/Track/[action]")]
public class TrackExampleController : Controller
{
SchoolContext _dataContext;
public TrackExampleController(SchoolContext dataContext)
{
// Sets the data context.
_dataContext = dataContext;
}
[HttpPost]
public string Example2(IDataUnpacker dataUnpacker)
{
// Uses IDataUnpack to receive JSON data from the client app.
var newStudent =
dataUnpacker.GetModelEntries<Person>("student").FirstOrDefault();
var example = new TrackExample(_dataContext);
example.Example2(newStudent);
return "SUCCESS";
}
[HttpPost]
public string Example3(IDataUnpacker dataUnpacker)
{
// Uses IDataUnpack to receive JSON data from the client app.
var newStudent = dataUnpacker.GetModelEntries<Person>("student")
.FirstOrDefault();
var newStudentGrade =
dataUnpacker.GetModelEntries<StudentGrade>("studentgrade")
.FirstOrDefault();
var example = new TrackExample(_dataContext);
example.Example3(newStudent, newStudentGrade);
return "SUCCESS";
}
}
}
Refer To
JSON Files: TrackExample2 TrackExample3