コード例 #1
0
        public MessageNoteOutput PostMessage(AddMessageInput input)
        {
            // 先判断此人发送者是否是管理员
            var existFromReporter = _reporterInfoRepo.FirstOrDefault(r => r.Id == input.FromReporterId && r.Type == 2);

            if (existFromReporter == null)
            {
                throw new UserFriendlyException("不是管理员权限");
            }

            var newMessageNote = new MessageNoteTb();

            // 如果是群发
            if (input.Type == 1)
            {
                var allRePorterType1 = _reporterInfoRepo.GetAll().Where(r => r.Type == 1).ToList();
                newMessageNote.ToReporter = allRePorterType1;
            }

            newMessageNote.FromReporter = existFromReporter;
            newMessageNote.Date         = DateTime.Now;
            newMessageNote.Flag         = 1; // 最新
            newMessageNote.Summary      = input.Summary;
            newMessageNote.Text         = input.Text;
            newMessageNote.Topic        = input.Topic;
            newMessageNote.Type         = input.Type;
            newMessageNote.Title        = input.Title;

            var id = _messageNoteRepo.InsertAndGetId(newMessageNote);

            newMessageNote.Id = id;

            return(newMessageNote.MapTo <MessageNoteOutput>());
        }
コード例 #2
0
        /// <summary>
        /// 添加投诉或建议
        /// </summary>
        /// <param name="input"></param>
        public void Add(AddMessageInput input)
        {
            var model = new Message
            {
                MessageType = input.MessageType,
                Content     = input.Content,
                MessageTime = DateTime.Now
            };

            using (var db = new RTDbContext())
            {
                db.Messages.Add(model);
                db.SaveChanges();
            }
        }
コード例 #3
0
        /// <summary>
        /// 添加投诉或建议
        /// </summary>
        /// <param name="input"></param>
        public GeneralResult Add(AddMessageInput input)
        {
            var result = new GeneralResult();

            try
            {
                bll.Add(input);
                result.State = 0;
                result.Msg   = "操作成功";
            }
            catch (RTException e)
            {
                result = RTExceptionHandle(e);
            }
            catch (Exception e1)
            {
                result = ExceptionHandle(e1);
            }
            return(result);
        }