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);
        }
Esempio n. 2
0
        /// <summary>
        /// 添加留言记录
        /// </summary>
        /// <param name="UserID"></param>
        /// <param name="Title"></param>
        /// <param name="Content"></param>

        /// <returns></returns>
        public long Add(long UserID, string Title, string Context)
        {
            using (MyDbContext dbcontext = new MyDbContext())
            {
                LeaveMsgEntity             leavwordsModel = new LeaveMsgEntity();
                CommonService <UserEntity> user           = new CommonService <UserEntity>(dbcontext);
                UserEntity uentity = user.GetById(UserID);
                leavwordsModel.UserID       = UserID;
                leavwordsModel.MsgTitle     = Title;
                leavwordsModel.MsgContent   = Context;
                leavwordsModel.LeaveTime    = DateTime.Now;
                leavwordsModel.IsRead       = 0;
                leavwordsModel.IsReply      = 0;
                leavwordsModel.FromUserType = 1;
                leavwordsModel.UserCode     = uentity.UserCode;
                leavwordsModel.FromIDIsDel  = 0;
                leavwordsModel.ToIDIsDel    = 0;
                leavwordsModel.ToUserType   = 2;
                leavwordsModel.ToUserID     = 1;
                leavwordsModel.ToUserCode   = "admin";
                dbcontext.LeaveMsg.Add(leavwordsModel);
                dbcontext.SaveChanges();
                return(leavwordsModel.ID);
            }
        }
 /// <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);
     }
 }
        /// <summary>
        /// 添加留言记录
        /// </summary>
        /// <param name="UserID"></param>
        /// <param name="Title"></param>
        /// <param name="Content"></param>

        /// <returns></returns>
        public long Add(long UserID, string Title, string Context)
        {
            using (MyDbContext dbcontext = new MyDbContext())
            {
                LeaveMsgEntity leavwordsModel = new LeaveMsgEntity();
                UserEntity     uentity        = dbcontext.User.SingleOrDefault(u => u.ID == UserID);
                leavwordsModel.UserID       = UserID;
                leavwordsModel.MsgTitle     = Title;
                leavwordsModel.MsgContent   = Context;
                leavwordsModel.LeaveTime    = DateTime.Now;
                leavwordsModel.IsRead       = 0;
                leavwordsModel.IsReply      = 0;
                leavwordsModel.FromUserType = 1;
                leavwordsModel.UserCode     = uentity.UserCode;
                leavwordsModel.FromIDIsDel  = 0;
                leavwordsModel.ToIDIsDel    = 0;
                leavwordsModel.ToUserType   = 2;
                leavwordsModel.ToUserID     = 1;
                leavwordsModel.ToUserCode   = "admin";
                dbcontext.LeaveMsg.Add(leavwordsModel);
                dbcontext.SaveChanges();
                return(leavwordsModel.ID);
            }
        }