I am converting a project from ASP.net Forms to ASP.Net MVC Core.
I'm creating a new recipient, and that recipient can have multiple contact methods.
The Add Contact Methods button brings up the following Modal:
In my ASP.Net forms app, I had a repeater, and I just added a new element to the repeater, and then when the form was submitted, I would iterate through the repeater's rows and populate my database.
How would one do this in MVC? Do I just create an html table and iterate through those rows?
I am new to MVC, so I am not sure how to proceed here.
For reference here is my data model for recipients and their contact methods:
public class Recipient
{
[Key]
public Guid RecipientGUID { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public string Company { get; set; }
public UserGroup Owner { get; set; }
public List<ContactMethod> ContactMethods { get; set; }
public User CreatedBy { get; set; }
public DateTime CreatedOn { get; set; }
public User LastModifiedBy { get; set; }
public DateTime LastModifiedOn { get; set; }
public bool IsActive { get; set; }
}
Contact Methods:
public class ContactMethod
{
[Key]
[HiddenInput(DisplayValue = false)]
public Guid ContactMethodGUID { get; set; }
[Required(ErrorMessage = "Please specify a type.")]
public ContactMethodType Type { get; set; }
[Required]
public Recipient Recipient { get; set; }
public int CountryCode { get; set; }
[Required(ErrorMessage = "Please enter a identifier.")]
public string Identifier { get; set; }
public bool IsPreferred { get; set; }
}