Show / Hide Table of Contents

    Controller: ImportEntryExampleController.cs

    using SnapObjects.Data;
    using Microsoft.AspNetCore.Mvc;
    using System.Linq;
    using DWNet.Data;
    using Appeon.ApiDoc.Models;
    using Appeon.ApiDoc.IDataStoreBaseExamples;
    
    namespace Appeon.ApiDoc.IDataStoreExamples
    {
        [Route("examples/IDataStore/ImportEntry/[action]")]
        public class ImportEntryExampleController : Controller
        {
            private readonly SchoolContext _dataContext;
    
            public ImportEntryExampleController(SchoolContext dataContext)
            {
                _dataContext = dataContext;
            }
    
            [HttpPost]
            public string Example1(IDataUnpacker dataUnpacker)
            {
                // Uses IDataUnpack to receive JSON data from the PB client app.
    
                // Gets the data of Person from the PB client app.
                var person = dataUnpacker.GetModelEntries<D_Person>("person").FirstOrDefault();
    
                // Saves data.
                var example = new ImportEntryExample(_dataContext);
                example.Example1(person);
    
                return "SUCCESS";
            }
    
            [HttpPost]
            public string Example2(IDataUnpacker dataUnpacker)
            {
                // Uses IDataUnpack to receive JSON data from the PB client app.
    
                // Gets the data of Person from the PB client app.
                var persons = dataUnpacker.GetModelEntries<D_Person>("person");
    
                // Saves data.
                var example = new ImportEntryExample(_dataContext);
                example.Example2(persons);
    
                return "SUCCESS";
            }
        }
    }
    

    Refer To

    JSON Files: ImportEntryExample ImportEntryExample

    Back to top Generated by Appeon