Controller: TrackGrandDetailsExampleController.cs
using SnapObjects.Data;
using Appeon.ApiDoc.Models.School;
using Microsoft.AspNetCore.Mvc;
using System.Linq;
namespace Appeon.ApiDoc.IDetailTrack
{
public class TrackGrandDetailsExampleController : Controller
{
private readonly SchoolContext _dataContext;
public TrackGrandDetailsExampleController(SchoolContext dataContext)
{
_dataContext = dataContext;
}
[HttpPost]
public string Example(IDataUnpacker dataUnpacker)
{
// Uses IDataUnpack to receive JSON data from the client app.
// Gets the data of Department, Course, and CourseStudent from the client app.
var department = dataUnpacker
.GetModelEntries<DepartmentInfo>("departmentinfo")
.FirstOrDefault();
var course = dataUnpacker
.GetModelEntries<CourseInfo>("courseinfo")
.FirstOrDefault();
var courseStudent = dataUnpacker
.GetModelEntries<CourseStudentInfo>("coursestudent");
// Saves data.
var example = new IDetailTrackerExamples
.TrackGrandDetailsExample(_dataContext);
example.Example(department, course, courseStudent);
return "SUCCESS";
}
}
}
Refer To
JSON File: TrackGrandDetailsExample