本文整理汇总了C#中Company.AddUser方法的典型用法代码示例。如果您正苦于以下问题:C# Company.AddUser方法的具体用法?C# Company.AddUser怎么用?C# Company.AddUser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Company
的用法示例。
在下文中一共展示了Company.AddUser方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BuildUserEntities
protected static void BuildUserEntities() {
//
// Company
//
var company = new Company
{
Name = "리얼웹",
Code = CompanyCode
};
Repository<Company>.SaveOrUpdate(company);
UnitOfWork.Current.TransactionalFlush();
//
// Department
//
Department parent = null;
foreach(var code in GetCodes("Dept", 5)) {
var dept = new Department(company, code)
{
Name = "부서." + code
};
if(parent != null)
dept.SetParent(parent);
Repository<Department>.SaveOrUpdate(dept);
parent = dept;
}
UnitOfWork.Current.TransactionalFlush();
//
// User
//
var i = 0;
foreach(var code in GetCodes("User", 25)) {
var user = new User(company, code, code)
{
Password = Password
};
company.AddUser(user);
user.Data = "동해물과 백두산이 마르고 닳도록, 하느님이 보우하사 우리나라 만세".Replicate(10);
user.Blob = Encoding.UTF8.GetBytes(user.Data);
user.ActivePeriod = (i++ % 2 == 0)
? new TimeRange(DateTime.Now.AddDays(-1), null)
: new TimeRange(null, DateTime.Now.AddDays(1));
user.ActiveYearWeek = new YearAndWeek(2009, 1);
user.PeriodTime = new PeriodTime
{
Period = new MonthRange(DateTime.Now),
//DateTime.Now.GetRelativeMonthRange(1),
YearWeek = new YearAndWeek(2009, 50)
};
Repository<User>.SaveOrUpdate(user);
}
UnitOfWork.Current.TransactionalFlush();
//
// DepartmentMember
//
var depts = Repository<Department>.FindAll();
var users = Repository<User>.FindAll();
foreach(var dept in depts) {
foreach(var user in users) {
var deptMember = new DepartmentMember(dept, user) { IsActive = true };
Repository<DepartmentMember>.SaveOrUpdate(deptMember);
}
}
UnitOfWork.Current.TransactionalFlush();
}