/// <summary>
 /// Create a new Laboratory_Staff object.
 /// </summary>
 /// <param name="staffId">Initial value of the StaffId property.</param>
 /// <param name="firstName">Initial value of the FirstName property.</param>
 /// <param name="lastName">Initial value of the LastName property.</param>
 /// <param name="emailAddress">Initial value of the EmailAddress property.</param>
 /// <param name="idNumber">Initial value of the IdNumber property.</param>
 /// <param name="courseAndYear">Initial value of the CourseAndYear property.</param>
 /// <param name="type">Initial value of the Type property.</param>
 /// <param name="userName">Initial value of the UserName property.</param>
 /// <param name="laboratoryId">Initial value of the LaboratoryId property.</param>
 public static Laboratory_Staff CreateLaboratory_Staff(global::System.Int32 staffId, global::System.String firstName, global::System.String lastName, global::System.String emailAddress, global::System.String idNumber, global::System.String courseAndYear, global::System.String type, global::System.String userName, global::System.Int32 laboratoryId)
 {
     Laboratory_Staff laboratory_Staff = new Laboratory_Staff();
     laboratory_Staff.StaffId = staffId;
     laboratory_Staff.FirstName = firstName;
     laboratory_Staff.LastName = lastName;
     laboratory_Staff.EmailAddress = emailAddress;
     laboratory_Staff.IdNumber = idNumber;
     laboratory_Staff.CourseAndYear = courseAndYear;
     laboratory_Staff.Type = type;
     laboratory_Staff.UserName = userName;
     laboratory_Staff.LaboratoryId = laboratoryId;
     return laboratory_Staff;
 }
 /// <summary>
 /// Deprecated Method for adding a new object to the Laboratory_Staff EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToLaboratory_Staff(Laboratory_Staff laboratory_Staff)
 {
     base.AddObject("Laboratory_Staff", laboratory_Staff);
 }
        public ActionResult Staff(itmmAdminStaff model, string type)
        {
            if (ModelState.IsValid) {
            AccountMembershipService MembershipService = new AccountMembershipService();
            MembershipCreateStatus createStatus = MembershipService.CreateUser(model.uname, model.password, model.eadd);
            if (createStatus == MembershipCreateStatus.Success) {

                Roles.AddUserToRole(model.uname, "Staff");

                Laboratory_Staff a = new Laboratory_Staff();
                a.FirstName = model.fname;
                a.LastName = model.lname;
                a.IdNumber = model.cnum;
                a.CourseAndYear = model.course;
                a.EmailAddress = model.eadd;
                a.Type = type;
                a.UserName = model.uname;
                //for LabId
                var c = (from y in con.Laboratories
                         where y.UserName == User.Identity.Name
                         select y.LaboratoryId).FirstOrDefault();
                a.LaboratoryId = c;
                con.AddToLaboratory_Staff(a);
                con.SaveChanges();

                return RedirectToAction("Staff", "Head");
            }
            else
            {
                ModelState.AddModelError("", AccountValidation.ErrorCodeToString(createStatus));
            }
            }
            return View(model);
        }