Controller: TrackMasterExampleController.cs
using SnapObjects.Data;
using Appeon.ApiDoc.Models.School;
using Microsoft.AspNetCore.Mvc;
using System.Linq;
namespace Appeon.ApiDoc.ISqlModelMapperExamples
{
[Route("examples/ISqlModelMapper/TrackMaster/[action]")]
public class TrackMasterExampleController : Controller
{
private readonly SchoolContext _dataContext;
public TrackMasterExampleController(SchoolContext dataContext)
{
_dataContext = dataContext;
}
[HttpPost]
public string Example1(IDataUnpacker dataUnpacker)
{
// Uses IDataUnpack to receive JSON data from the client app.
// Gets the data of Course and OnlineCourse from the client app.
var course = dataUnpacker.GetModelEntries<CourseAndOnlineInfo>("course")
.FirstOrDefault();
var onlineCourse =
dataUnpacker.GetModelEntries<OnlineCourse>("onlinecourse")
.FirstOrDefault();
// Saves data.
var example =
new TrackMasterExample(_dataContext);
example.Example1(course, onlineCourse);
return "SUCCESS";
}
[HttpPost]
public string Example2(IDataUnpacker dataUnpacker)
{
// Uses IDataUnpack to receive JSON data from the client app.
// Gets the data of Course from the client app.
var course = dataUnpacker.GetModelEntries<CourseAndOnlineInfo>("course")
.FirstOrDefault();
// Saves data.
var example = new TrackMasterExample(_dataContext);
example.Example2(course);
return "SUCCESS";
}
}
}
Refer To
JSON Files: TrackMasterExample1 TrackMasterExample2