public void Add(ModelViewHuman request) { var maNhanVien = _context.PERSONALS.Count <PERSONAL>() + 1; EMPLOYMENT nhanvien = new EMPLOYMENT { EMPLOYMENT_ID = maNhanVien, HIRE_DATE_FOR_WORKING = request.HIRE_DATE_FOR_WORKING, NUMBER_DAYS_REQUIREMENT_OF_WORKING_PER_MONTH = request.NUMBER_DAYS_REQUIREMENT_OF_WORKING_PER_MONTH, }; _context.EMPLOYMENTS.Add(nhanvien); _context.SaveChanges(); PERSONAL canhan = new PERSONAL { EMPLOYEE_ID = maNhanVien, CURRENT_FIRST_NAME = request.CURRENT_FIRST_NAME, CURRENT_LAST_NAME = request.CURRENT_LAST_NAME, BIRTH_DATE = request.BIRTH_DATE, CURRENT_ADDRESS_1 = request.CURRENT_ADDRESS_1, CURRENT_GENDER = request.CURRENT_GENDER, CURRENT_PHONE_NUMBER = request.CURRENT_PHONE_NUMBER, CURRENT_PERSONAL_EMAIL = request.CURRENT_PERSONAL_EMAIL, }; _context.PERSONALS.Add(canhan); _context.SaveChanges(); }
public ActionResult Create([Bind(Include = "Email,FirstName,Password")] HumanTb humanTb) { if (ModelState.IsValid) { db.HumanTbs.Add(humanTb); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(humanTb)); }
public ActionResult SignUp(HumanTb obj) { obj.Email = obj.Email.Trim(); HumanDbContext db = new HumanDbContext(); db.HumanTbs.Add(obj); db.SaveChanges(); return(RedirectToAction("Login")); }
// } public void Add(ModelViewAdmin request) { //var id = _contextHuman.EMPLOYMENTS.Count<EMPLOYMENT>() + 1; EMPLOYMENT employment = new EMPLOYMENT { //EMPLOYMENT_ID = id, HIRE_DATE_FOR_WORKING = request.HIRE_DATE_FOR_WORKING, EMPLOYMENT_STATUS = request.EMPLOYMENT_STATUS, }; _contextHuman.EMPLOYMENTS.Add(employment); _contextHuman.SaveChanges(); var id = _contextHuman.EMPLOYMENTS.FromSqlRaw("SELECT TOP 1 * FROM EMPLOYMENT ORDER BY EMPLOYMENT_ID DESC ").FirstOrDefault(); //var id = _contextHuman.EMPLOYMENTS.Last<EMPLOYMENT>(); PERSONAL personal = new PERSONAL { EMPLOYEE_ID = id.EMPLOYMENT_ID, CURRENT_FIRST_NAME = request.CURRENT_FIRST_NAME, CURRENT_LAST_NAME = request.CURRENT_LAST_NAME, BIRTH_DATE = request.BIRTH_DATE, SOCIAL_SECURITY_NUMBER = request.SOCIAL_SECURITY_NUMBER, CURRENT_ADDRESS_1 = request.CURRENT_ADDRESS_1, CURRENT_GENDER = request.CURRENT_GENDER, CURRENT_PHONE_NUMBER = request.CURRENT_PHONE_NUMBER, CURRENT_PERSONAL_EMAIL = request.CURRENT_PERSONAL_EMAIL, }; _contextHuman.PERSONALS.Add(personal); _contextHuman.SaveChanges(); employee employee = new employee { idEmployee = id.EMPLOYMENT_ID, LastName = request.CURRENT_LAST_NAME, FirstName = request.CURRENT_FIRST_NAME, PayRatesidPayRates = request.PayRatesidPayRates, VacationDays = request.VacationDays, }; _contextPayroll.employees.Add(employee); _contextPayroll.SaveChanges(); }