Show / Hide Table of Contents

    Controller: TrackDetailExampleController.cs

    using SnapObjects.Data;
    using Appeon.ApiDoc.Models.School;
    using Microsoft.AspNetCore.Mvc;
    using System.Linq;
    
    namespace Appeon.ApiDoc.IDetailTrack
    {
        [Route("examples/IDetailTrack/TrackDetail/[action]")]
        public class SetValueAttributeExampleController : Controller
        {
            private readonly SchoolContext _dataContext;
    
            public SetValueAttributeExampleController(SchoolContext dataContext)
            {
                _dataContext = dataContext;
            }
    
            [HttpPost]
            public string Example(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 onlineCourses = dataUnpacker.GetModelEntries<OnlineCourse>("onlinecourse")
                                    .FirstOrDefault();
    
                // Saves data.
                var example = new IDetailTrackerExamples.TrackDetailExample(_dataContext);
                example.Example(course, onlineCourses);
    
                return "SUCCESS";
            }
    
        }
    }
    

    Refer To

    JSON File: TrackDetailExample

    Back to top Generated by Appeon