I have a two tables
RegisterTable : FirstName
LastName
UserName
Password
UserLoginTable : UserName
Password
I want to insert the datas into multiple tables from same control. I am inserting data into Register Table and simaltaneously I want the data to be inserted into UserLogin Table but only the UserName and Password into UserLogin Table as my UserLogin Table contains ony UserName and Password Column.
My Conntroller
public class RegisterController : Controller
{
private IRegisterService registerService;
public RegisterController(IRegisterService _registerService)
{
registerService = _registerService;
}
//GET: Register
public ActionResult Index()
{
List<RegisterDTO> registers = registerService.GetAllRegisters();
return View(registers.ToList());
}
[HttpGet]
public ActionResult Create()
{
return View();
}
[HttpPost]
public ActionResult Create(RegisterDTO registerDTO)
{
try
{
bool isSaved;
if (registerDTO.Id == 0)
isSaved = registerService.Create(registerDTO);
else
return View();
}
My Both Models
public class RegisterDTO
{
public int Id { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public string UserName { get; set; }
public string Password { get; set; }
}
public class UserLoginDTO
{
public int Id { get; set; }
public string UserName { get; set; }
public string Password { get; set; }
}