Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. add data to more table relation in same time

add data to more table relation in same time

Scheduled Pinned Locked Moved ASP.NET
databasecsharpvisual-studiojsoncareer
2 Posts 1 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    ahmed_sa
    wrote on last edited by
    #1

    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

    A 1 Reply Last reply
    0
    • A ahmed_sa

      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

      A Offline
      A Offline
      ahmed_sa
      wrote on last edited by
      #2

      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(); }

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups