예제 #1
0
        /// <summary>
        /// 发布通知接口
        /// </summary>
        /// <param name="VisitorID">游客ID,如果Admin代表管理员</param>
        /// <param name="NoticeType"></param>
        /// <param name="OccurTime"></param>
        /// <param name="OccurAddress"></param>
        /// <param name="NoticeDetail"></param>
        /// <returns></returns>
        public Stream PublishNotice(string VisitorID, int NoticeType, string OccurTime, string OccurAddress, string NoticeDetail)
        {
            if (VisitorID != "Admin" && NoticeType == 2)//合法性检查
            {
                return(ResponseHelper.Failure("只有管理员可以发布活动通知!"));
            }

            string id     = IDHelper.getNextNoticeID(DateTime.Now);
            Notice notice = new Notice()
            {
                NoticeID     = id,
                VisitorID    = VisitorID,
                NoticeType   = NoticeType,
                NoticeTime   = DateTime.Now,
                OccurTime    = OccurTime,
                OccurAddress = OccurAddress,
                NoticeDetail = NoticeDetail,
                NoticeStatus = 0,
                Remarks      = "",
                CheckTime    = null
            };

            if (VisitorID == "Admin")
            {
                notice.NoticeStatus = 1;
                notice.CheckTime    = DateTime.Now;
            }


            try
            {
                EFHelper.Add <Notice>(notice);  //通知信息提交数据库
                return(ResponseHelper.Success(new List <string>()
                {
                    "发布成功,等待审核!"
                }));
            }
            catch (Exception ex)
            {
                while (ex.InnerException != null)
                {
                    ex = ex.InnerException;
                }
                return(ResponseHelper.Failure(ex.Message));
            }
        }