add data to more table relation in same time
-
I need to make multiple insert to multiple table have relation with each other all id in all table is identity and already do model relation ef to it in visual studio 2015 what i need actually when user click submit Save the following data Name,Email,Salary,DistrictId in table Employee EmployeeId,CourseId in table EmployeeCourse EmployeeId,LanaguageId,LevelId in table EmployeeLangage what i write in create function in empcourse controller my custom model as following [code] public class Customemployee { public string Name { get; set; } public string Salary { get; set; } public string Email { get; set; } public int DistrictId { get; set; } public List Courses { get; set; } public List Langs { get; set; } } public class Empcourse { public int Id { get; set; } public int EmployeeId { get; set; } public int CourseId { get; set; } } public class Emplangauge { public int Id { get; set; } public int LevelId { get; set; } public int LanguageId { get; set; } } } [/code] my controller empcourse is [code] public class empcourseController : Controller { mycourseEntities db = new mycourseEntities(); // GET: empcourse public ActionResult Index() { return View(); } public ActionResult Create() { ViewBag.CountryId = new SelectList(db.Countries.ToList(), "Id", "CountryName"); ViewBag.LanaguageId = new SelectList(db.Languages.ToList(), "Id", "LnaguageName"); ViewBag.LevelId = new SelectList(db.Levels.ToList(), "Id", "LevelName"); ViewBag.CourseId = new SelectList(db.Courses.ToList(), "Id", "CourseName"); return View(); } [HttpPost] public ActionResult Create(Customemployee cemp) { return View(); } public JsonResult getcitybyid(int id) { db.Configuration.ProxyCreationEnabled = false; return Json(db.Cities.Where(a => a.CountryId == id), JsonRequestBehavior.AllowGet); } public JsonResult getdistrictbyid(int id) { d
-
I need to make multiple insert to multiple table have relation with each other all id in all table is identity and already do model relation ef to it in visual studio 2015 what i need actually when user click submit Save the following data Name,Email,Salary,DistrictId in table Employee EmployeeId,CourseId in table EmployeeCourse EmployeeId,LanaguageId,LevelId in table EmployeeLangage what i write in create function in empcourse controller my custom model as following [code] public class Customemployee { public string Name { get; set; } public string Salary { get; set; } public string Email { get; set; } public int DistrictId { get; set; } public List Courses { get; set; } public List Langs { get; set; } } public class Empcourse { public int Id { get; set; } public int EmployeeId { get; set; } public int CourseId { get; set; } } public class Emplangauge { public int Id { get; set; } public int LevelId { get; set; } public int LanguageId { get; set; } } } [/code] my controller empcourse is [code] public class empcourseController : Controller { mycourseEntities db = new mycourseEntities(); // GET: empcourse public ActionResult Index() { return View(); } public ActionResult Create() { ViewBag.CountryId = new SelectList(db.Countries.ToList(), "Id", "CountryName"); ViewBag.LanaguageId = new SelectList(db.Languages.ToList(), "Id", "LnaguageName"); ViewBag.LevelId = new SelectList(db.Levels.ToList(), "Id", "LevelName"); ViewBag.CourseId = new SelectList(db.Courses.ToList(), "Id", "CourseName"); return View(); } [HttpPost] public ActionResult Create(Customemployee cemp) { return View(); } public JsonResult getcitybyid(int id) { db.Configuration.ProxyCreationEnabled = false; return Json(db.Cities.Where(a => a.CountryId == id), JsonRequestBehavior.AllowGet); } public JsonResult getdistrictbyid(int id) { d
can you help me what i need actually insert Save the following data Name,Email,Salary,DistrictId in table Employee EmployeeId,CourseId in table EmployeeCourse EmployeeId,LanaguageId,LevelId in table EmployeeLangage and write it in Create http post [HttpPost] public ActionResult Create(Customemployee cemp) { return View(); }