public int Create(string Login, string Hash, bool Active, int?EmployeeID) { int result = 1; SecurityUser sr = SecurityUser.CreateSecurityUser(1, true); sr.Login = Login; sr.Hash = Hash; sr.Active = Active; if (EmployeeID != null) { int employeeId = Convert.ToInt32(EmployeeID); StaffEmployee e = (from a in context.StaffEmployees where a.ID == employeeId select a).FirstOrDefault(); e.SecurityUser = sr; } context.AddToSecurityUsers(sr); result = sr.ID; return(result); }