public LeaveMsgDTO ToDTO(LeaveMsgEntity msg) { LeaveMsgDTO LeaveMsg = new LeaveMsgDTO(); LeaveMsg.ID = msg.ID; LeaveMsg.MsgTitle = msg.MsgTitle; LeaveMsg.MsgContent = msg.MsgContent; LeaveMsg.LeaveTime = msg.LeaveTime; LeaveMsg.IsRead = msg.IsRead; LeaveMsg.IsReply = msg.IsReply; LeaveMsg.IsReplyName = msg.IsReply == 0 ? "未回复" : "已回复"; LeaveMsg.FromUserType = msg.FromUserType; LeaveMsg.UserID = Convert.ToInt64(msg.UserID); LeaveMsg.FromIDIsDel = Convert.ToInt32(msg.FromIDIsDel); LeaveMsg.UserCode = msg.UserCode; LeaveMsg.ToUserType = msg.ToUserType; LeaveMsg.ToUserID = Convert.ToInt32(msg.ToUserID); LeaveMsg.ToUserCode = msg.ToUserCode; LeaveMsg.ToIDIsDel = Convert.ToInt32(msg.ToIDIsDel); LeaveMsg.IsDeleted = msg.IsDeleted; LeaveMsg.CreateTime = msg.CreateTime; //LeaveMsg.LeaveOutName = userService.GetUserCodeForMessage(LeaveMsg.ToUserID, LeaveMsg.ToUserType); //LeaveMsg.LeaveInName = userService.GetUserCodeForMessage(LeaveMsg.UserID, LeaveMsg.FromUserType); return(LeaveMsg); }
/// <summary> /// 根据ID查询 /// </summary> /// <param name="ID"></param> /// <returns></returns> public LeaveMsgDTO GetModelByID(long ID) { using (MyDbContext dbcontext = new MyDbContext()) { CommonService <LeaveMsgEntity> csr = new CommonService <LeaveMsgEntity>(dbcontext); LeaveMsgEntity take = csr.GetById(ID); LeaveMsgDTO model = null; if (take != null) { model = ToDTO(take); } return(model); } }