public void Save(BO.DepartmentBO o)
 {
     DAL.DepartmentDAL dal = new DAL.DepartmentDAL();
        dal.Save(o);
 }
Exemple #2
0
        //internal static Common.UserModel GetUserModel(string accountName)
        //{
        //    if (UserProvider.Users.ContainsKey(accountName))
        //        return UserProvider.Users[accountName];

        //    RegisterUserModel(accountName);

        //    return UserProvider.Users[accountName];
        //}

        private static Common.ResultModel RegisterUserSecurity(string ticket, string accountName)
        {
            Common.ResultModel result = null;

            UserSecurity security = new UserSecurity();

            security.CookieValue = ticket;
            //Account
            Model.Account  account    = null;
            DAL.AccountDAL accountDal = new DAL.AccountDAL();
            security.Account = accountDal.Find(acc => acc.AccountName == "accountName");

            //Employee
            Model.Employee  emp    = null;
            DAL.EmployeeDAL empDal = new DAL.EmployeeDAL();
            security.Emp = empDal.Find(e => e.EmpId == account.EmpId);

            //Department
            Model.Department  dept    = new Model.Department();
            DAL.DepartmentDAL deptDal = new DAL.DepartmentDAL();
            security.Dept = deptDal.Find(d => d.DeptId == emp.DeptId);

            //Corporation
            Model.Corporation  corp    = new Model.Corporation();
            DAL.CorporationDAL corpDal = new DAL.CorporationDAL();
            security.Corp = corpDal.Find(c => c.CorpId == dept.CorpId);

            //Bloc
            Model.Bloc  bloc    = new Model.Bloc();
            DAL.BlocDAL blocDal = new DAL.BlocDAL();
            if (security.Corp != null)
            {
                security.Bloc = blocDal.Find(b => b.BlocId == security.Corp.ParentId);
            }

            //Role
            List <Model.Role> roles = new List <Model.Role>();

            DAL.RoleDAL roleDal = new DAL.RoleDAL();
            result = roleDal.Load(emp.EmpId);
            if (result.ResultStatus == 0)
            {
                roles = result.ReturnValue as List <Model.Role>;
            }
            security.Roles = roles;

            //Menu
            List <Model.Menu> menus = new List <Model.Menu>();

            DAL.MenuDAL menuDal = new DAL.MenuDAL();
            result = menuDal.Load(emp.EmpId);
            if (result.ResultStatus == 0)
            {
                menus = result.ReturnValue as List <Model.Menu>;
            }
            security.Menus = menus;

            Common.UserModel user = security;
            user.AccountId   = security.Account.AccId;
            user.AccountName = security.Account.AccountName;
            user.EmpId       = security.Emp.EmpId;
            user.EmpName     = security.Emp.Name;
            user.CorpId      = security.Corp.CorpId;
            user.DeptId      = security.Dept.DeptId;

            lock (Securities)
            {
                if (!Securities.ContainsKey(accountName))
                {
                    Securities.Add(accountName, security);
                }
            }

            result.ResultStatus = 0;
            return(result);
        }