I have a model class. That class contains multiple properties , list of custom class and list of formfile data. I need to create post request for this model using Asp.net Core.
Model Class
public class TenoModel
{
[Key]
public int Id { get; set; }
public DateTime Date { get; set; }
public float Salary { get; set; }
[Required]
public string User { get; set; }
public List<IformFile> files {get;set;}
public List<Employee> employees{get;set;}
}
Custom class for employee
public class Employee
{
public int Id {get;set;}
public string Name {get;set;}
public double Salary {get;set;}
}
HttpPost request:
[HttpPost("CreateTeno")]
[Consumes('multipart/form-data']
public async Task<IActionResult> CreateTeno([FormFile] TenoModel model)
{
..... save the model data to teno database
}
When I execute the HttpPost request on swagger Formfile data and some property data come to incoming request on CreateTeno method. I fill the Employee object also in swagger. but that data not coming in my CreateTeno method. List of Employee data count zero. How to pass model class with multiple properties, List of IformFile and multiple list customclass in HTTP post request. Give a sample example.
