/// <summary> /// 查看用户 /// </summary> /// <param name="request"></param> /// <returns></returns> public DTO.PSUserView UserView(DTO.PQUserView request) { DTO.PSUserView response = new DTO.PSUserView(); try { using (var scope = new System.Transactions.TransactionScope()) { Models.tbUser u = new Models.tbUser(); //修改 if (request.UserID > 0) { u = con.tbUser.Find(request.UserID); response.UserID = u.UserID; response.UserAccount = u.UserAccount; response.UserName = u.UserName; response.StartDate = u.StartDate.ToString("yyyy-MM-dd"); response.EndDate = u.EndDate.ToString("yyyy-MM-dd"); response.LastLoginTime = u.LastLoginTime == null ? "" : ((DateTime)u.LastLoginTime).ToString("yyyy-MM-dd HH:mm:ss"); response.CreateTime = u.CreateTime.ToString("yyyy-MM-dd HH:mm:ss"); response.UpdateTime = u.UpdateTime.ToString("yyyy-MM-dd HH:mm:ss"); response.OrgID = (int)u.OrgID; Models.tbOrg o = con.tbOrg.Find(response.OrgID); response.FullPath = o.FullPath; response.RoleID = (int)u.RoleID; Models.tbRole r = con.tbRole.Find(response.RoleID); response.RoleName = r.RoleName; response.CellPhone = u.CellPhone; response.Email = u.Email; response.WorkNumber = u.WorkNumber; } List <Models.tbOrg> orgs = con.tbOrg.OrderBy(p => p.RealPath).ToList(); foreach (Models.tbOrg org in orgs) { response.OrgList.Add(new KeyValuePair <int, string>(org.OrgID, org.FullPath)); } List <Models.tbRole> roles = con.tbRole.Where(p => p.RoleType == "1").OrderBy(p => p.RoleID).ToList(); foreach (Models.tbRole role in roles) { response.RoleList.Add(new KeyValuePair <int, string>(role.RoleID, role.RoleName)); } response.ErrorCode = "A_0"; } } catch (Exception ex) { LogHelper.Error("cUserBLL.UserView出错!", ex); throw; } response.ErrorMessage = rm.GetString(response.ErrorCode); return(response); }
public DTO.PSRoleModify RoleModify(DTO.PQRoleModify request) { DTO.PSRoleModify response = new DTO.PSRoleModify(); try { using (var scope = new System.Transactions.TransactionScope()) { Models.tbRole role = new Models.tbRole(); if ("1".Equals(request.IsDel)) { role = con.tbRole.Find(request.RoleID); con.tbRole.Remove(role); } else { if (request.RoleID > 0) { role = con.tbRole.Find(request.RoleID); role.RoleName = request.RoleName; role.RoleType = request.RoleType; } else { role = con.tbRole.Create(); role.RoleName = request.RoleName; role.RoleType = request.RoleType; role = con.tbRole.Add(role); } } con.SaveChanges(); response.RoleID = role.RoleID; response.RoleName = role.RoleName; scope.Complete(); response.ErrorCode = "A_0"; } } catch (Exception ex) { LogHelper.Error("cUserBLL.RoleModify出错!", ex); throw; } response.ErrorMessage = rm.GetString(response.ErrorCode); return(response); }