public NhanVienViewModel Login(string userName, string password) { NhanVien account = (NhanVien)_nhanVienRepo.SearchFor(i => i.UserName.Equals(userName) && i.PassWord.Equals(password)).SingleOrDefault(); if (account != null) { var thongTinNhanVien = (from nhanvien in _nhanVienRepo.GetAll() join chucvu in _chucVuRepo.GetAll() on nhanvien.MaChucVu equals chucvu.MaChucVu orderby nhanvien.MaNhanVien descending where nhanvien.MaNhanVien.Equals(account.MaNhanVien) select new NhanVienViewModel { maNhanVien = nhanvien.MaNhanVien, tenNhanVien = nhanvien.TenNhanvien, diaChi = nhanvien.DiaChi, soDienThoai = nhanvien.SoDienThoai, email = nhanvien.Email, CMND = nhanvien.CMND, avatar = nhanvien.Avatar, maChucVu = nhanvien.MaChucVu, tenChucVu = chucvu.TenChucVu, trangThai = nhanvien.TrangThai, }).First(); return((NhanVienViewModel)thongTinNhanVien); } else { return(null); } }
public List <Object> LoadChucVu() { IQueryable <ChucVu> dsChucVu = _chucVuRepo.GetAll(); int[] IDs = { 4, 5, 6, 7 }; var list = (from chucvu in dsChucVu where IDs.Contains(chucvu.MaChucVu) select new SelectListItem { Text = chucvu.TenChucVu, Value = chucvu.MaChucVu.ToString(), }); return(new List <Object>(list)); }
public ActionResult Create() { var cvs = ChucVuRepository.GetAll().Select(x => x.ToDataInfo()).ToList(); var roles = RoleRepository.GetAll().Select(x => x.ToRoleViewModel()).ToList(); var cqs = CoQuanRepository.GetAll().Select(x => x.ToDataInfo()).ToList(); var userInfo = new AddUserViewModel { RoleInfos = roles, ChucVuInfos = cvs, CoQuanInfos = cqs, }; return(View(userInfo)); }
public ActionResult Edit(int id) { var user = UserRepository.Single(id); var chucvu = ChucVuRepository.GetAll().Select(x => x.ToDataInfo()); var coQuan = CoQuanRepository.GetAll().Select(x => x.ToDataInfo()); var userRole = UserRoleRepository.GetRolesByUserId(id); var roles = RoleRepository.GetAll().ToList(); roles.ForEach(x => { userRole.ToList().ForEach(y => { if (y.RoleId == x.Id) { x.IsChecked = true; } }); }); AddUserViewModel model = new AddUserViewModel { Id = user.Id, FullName = user.HoVaTen, UserName = user.UserName, IsLocked = user.IsLocked, ChucVuId = user.ChucVuId, ChucVuInfos = chucvu, CoQuanId = user.CoQuanId, CoQuanInfos = coQuan, CreateDate = user.CreateDate, CreatedBy = user.CreatedBy, RoleInfos = roles.Select(x => x.ToRoleViewModel()).ToList(), }; return(View(model)); }
public ActionResult Index() { var listChucVu = chucvuRepo.GetAll(); return(View(listChucVu)); }