12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- using Central.Control.Domain;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace MES.Production.Service.ServiceImp
- {
-
-
-
-
- public class UserDepartmentManage:RepositoryBase<SYS_USER_DEPARTMENT>,IService.IUserDepartmentManage
- {
-
-
-
- public List<SYS_USER> GetUserListByDptId(List<string> dptId)
- {
- return this.LoadAll(p => dptId.Contains(p.DEPARTMENT_ID)).Select(p => p.SYS_USER).ToList();
- }
-
-
-
- public List<SYS_DISTRIBUTORS> GetDptListByUserId(int userId)
- {
- return this.LoadAll(p => p.USER_ID == userId).Select(p=>p.SYS_DISTRIBUTORS).ToList();
- }
-
-
-
-
-
- public bool SaveUserDpt(int userId, string dptId)
- {
- try
- {
-
- if (this.IsExist(p => p.USER_ID == userId))
- {
-
- var oldCount = this.LoadAll(p => p.USER_ID == userId && dptId.Contains(p.DEPARTMENT_ID)).Select(p => p.DEPARTMENT_ID).ToList();
- var newdptid = dptId.Split(',').OrderBy(c => c).ToList();
- if (oldCount.Count == newdptid.Count && oldCount.All(newdptid.Contains)) return true;
-
- this.Delete(p => p.USER_ID == userId);
- }
- if (!string.IsNullOrEmpty(dptId))
- {
-
- var list = dptId.Split(',').Select(item => new SYS_USER_DEPARTMENT()
- {
- DEPARTMENT_ID = item,
- USER_ID = userId
- }).ToList();
- return this.SaveList(list) > 0;
- }
- return true;
- }
- catch (Exception e) { throw e.InnerException; }
- }
- }
- }
|