Exemplo n.º 1
0
        public JsonResult NoticeNew(Notice entity, int receiverId = 0)
        {
            entity.Publisher    = this.GetLoginUser().Name;
            entity.CreateUserId = this.GetLoginUser().UserID;
            if (entity.Type == 0 && receiverId == 0)
            {
                return(Json(new { status = 0, msg = "没有设置消息接收人" }));
            }
            if (entity.NoticeId > 0)
            {
                Notice newNotice = bcBase.CurrentEntities.Notice.Where(n => n.NoticeId == entity.NoticeId).FirstOrDefault();
                if (newNotice.IsNoNull())//修改
                {
                    newNotice.Type          = entity.Type;
                    newNotice.Title         = entity.Title;
                    newNotice.NoticeContent = entity.NoticeContent;
                    newNotice.Publisher     = entity.Publisher;
                    newNotice.CreateUserId  = entity.CreateUserId;
                    bcBase.CurrentEntities.SaveChanges();
                    return(Json(new { status = newNotice.NoticeId }));
                }
            }
            int row = noticeBll.NoticeAdd(entity, receiverId);

            return(Json(new { status = row }));
        }