Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Html.DropDownList(model => model.Dept_ID, ViewBag.deptlistname as
- SelectList, "Please select a department");
- public ActionResult UserRegistration()
- {
- HREntities4 db = new HREntities4();
- var getdeptlist = db.departments.ToList();
- SelectList list = new SelectList(getdeptlist, "Dept_ID",
- "Dept_ID");
- ViewBag.deptlistname = list;
- return View();
- }
- [HttpPost]
- public ActionResult UserRegistration(UserRegistration model)
- {
- if (ModelState.IsValid)
- {
- var details = new HREntities4();
- details.logins.Add(new login{
- FirstName = model.FirstName,
- LastName = model.LastName,
- Username = model.Username,
- Email = model.Email,
- Password = model.Password,
- PhoneNumber =model.PhoneNumber,
- Address = model.Address,
- Hire_Date = model.Hire_Date,
- Salary = model.Salary,
- Dept_ID = model.Dept_ID
- });
- details.SaveChanges();
- ModelState.AddModelError("updated", "User has been registered");
- }
- return View();
- }
- public partial class UserRegistration
- {
- public string FirstName { get; set; }
- public string LastName { get; set; }
- public string Username { get; set; }
- public string Email { get; set; }
- public string Password { get; set; }
- public string PhoneNumber { get; set; }
- public string Address { get; set; }
- public string Hire_Date { get; set; }
- public Nullable<double> Salary { get; set; }
- public int Dept_ID { get; set; }
- }
Add Comment
Please, Sign In to add comment