Ejemplo n.º 1
0
        public UserDepartmentListViewModel GetUserDepartment(int Id)
        {
            UserDepartmentListViewModel rm = new UserDepartmentListViewModel();
            //bool b =await IsExist(a => a.UserId == Id);
            //if (!b)
            //{
            //    rm.Success = true;
            //    rm.Message = "该用户没有分配任何部门";
            //    return rm;
            //}
            var ud = _UserDepartment.FindWithDepartment(a => a.UserId == Id);

            foreach (var item in ud)
            {
                rm.Data.Add(new UserDepartmentData
                {
                    UserId             = item.UserId,
                    DepartmentId       = item.DeparmentId,
                    DepartmentName     = item.Department.DepartmentName,
                    DepartmentPathName = item.Department.PathName
                });
            }
            rm.Success = true;
            rm.Message = "获取数据成功";
            return(rm);
        }
Ejemplo n.º 2
0
 public ActionResult DeleteUsers(UserDepartmentListViewModel udlvm)
 {
     foreach (var ud in udlvm.UserDepartments)
     {
         _userDepartmentService.UpdateUserDepartment(udlvm.UserId, ud.DepartmentId, DateTime.ParseExact(ud.ValidFrom, "dd.MM.yyyy", CultureInfo.InvariantCulture), DateTime.ParseExact(ud.ValidTo, "dd.MM.yyyy", CultureInfo.InvariantCulture), ud.IsForDelete);
     }
     return(null);
 }
Ejemplo n.º 3
0
        public ActionResult AddUserDepartment(int userId)
        {
            UserDepartmentListViewModel udlvm = GetUserDepartmentListViewModel(userId);

            ((ICollection <UserDepartmentItem>)udlvm.UserDepartments).Add(new UserDepartmentItem()
            {
                UserId = userId, ValidFrom = DateTime.Now.ToString("dd.MM.yyyy"), ValidTo = DateTime.Now.ToString("dd.MM.yyyy")
            });
            return(PartialView("UserDepartmentList", udlvm));
        }