本文整理汇总了C#中Entities.GetId方法的典型用法代码示例。如果您正苦于以下问题:C# Entities.GetId方法的具体用法?C# Entities.GetId怎么用?C# Entities.GetId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Entities
的用法示例。
在下文中一共展示了Entities.GetId方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TeacherAdd
public bool TeacherAdd(Entities db, Guid campusId, Guid departmentId, int ordinal, string name, string phone, string passwordInitial, State state, string email, string idCard, bool? gender, DateTime? birthday, string nationality, string birthplace, string address, string account, bool? perstaff, bool sync, out Guid gid, string ex)
{
gid = db.GetId();
try
{
string key, salt;
var password = HomoryCryptor.Encrypt(passwordInitial, out key, out salt);
var user = new User
{
Id = gid,
Account = account,
RealName = name,
DisplayName = name,
Stamp = Guid.NewGuid(),
Type = UserType.教师,
Password = password,
PasswordEx = null,
CryptoKey = key,
CryptoSalt = salt,
Icon = "~/CommonX/默认/用户.png",
State = state,
Ordinal = ordinal,
Description = null
};
var userTeacher = new Homory.Model.Teacher
{
Id = user.Id,
Phone = phone,
Email = email,
Gender = gender,
Birthday = birthday,
Birthplace = birthplace,
Address = address,
Nationality = nationality,
IDCard = idCard,
PerStaff = perstaff ?? true,
Sync = sync
};
var relation = new DepartmentUser
{
DepartmentId = departmentId,
UserId = user.Id,
TopDepartmentId = campusId,
Type = DepartmentUserType.部门主职教师,
State = State.启用,
Ordinal = 0,
Time = DateTime.Now
};
db.User.Add(user);
db.Teacher.Add(userTeacher);
db.DepartmentUser.Add(relation);
db.SaveChanges();
try { UserHelper.InsertUserEx(name, "C984AED014AEC7623A54F0591DA07A85FD4B762D", sync, state, account, departmentId.ToString().ToUpper(), gid.ToString().ToUpper(), phone, idCard, ordinal, 0, "1000", ex); } catch { }
return true;
}
catch
{
return false;
}
}
示例2: StudentAdd
public bool StudentAdd(Entities db, Guid campusId, Guid classId, int ordinal, string name, string account, string passwordInitial, State state, string uniqueId, string idCard, bool? gender, DateTime? birthday, string nationality, string birthplace, string address, string charger, string chargerContact)
{
try
{
string key, salt;
var password = HomoryCryptor.Encrypt(passwordInitial, out key, out salt);
var user = new User
{
Id = db.GetId(),
Account = account,
RealName = name,
DisplayName = name,
Stamp = Guid.NewGuid(),
Type = UserType.学生,
Password = password,
PasswordEx = null,
CryptoKey = key,
CryptoSalt = salt,
Icon = "~/Common/默认/用户.png",
State = state,
Ordinal = ordinal,
Description = null
};
var userStudent = new Homory.Model.Student
{
Id = user.Id,
UniqueId = uniqueId,
Gender = gender,
Birthday = birthday,
Birthplace = birthplace,
Address = address,
Nationality = nationality,
IDCard = idCard,
Charger = charger,
ChargerContact = chargerContact
};
var relation = new DepartmentUser
{
DepartmentId = classId,
UserId = user.Id,
TopDepartmentId = campusId,
Type = DepartmentUserType.班级学生,
State = State.启用,
Ordinal = 0,
Time = DateTime.Now
};
db.User.Add(user);
db.Student.Add(userStudent);
db.DepartmentUser.Add(relation);
return true;
}
catch
{
return false;
}
}