Пример #1
0
        public async Task <ActionResult <InfoResult <AcNoticeDtos> > > Addnotice(AcNoticeDtos acNoticeDtos)
        {
            var noticeList = await _IAcNoticeService.Search(t => true);

            int max = 0;

            foreach (var item in noticeList)
            {
                if (item.Id > max)
                {
                    max = item.Id;
                }
            }
            acNoticeDtos.Id         = max + 1;
            acNoticeDtos.Createdate = DateTime.Now.ToString();
            InfoResult <AcNoticeDtos> messageModel = new InfoResult <AcNoticeDtos>();
            var data = await _IAcNoticeService.Add(_mapper.Map <AcNotice>(acNoticeDtos));

            if (data > 0)
            {
                messageModel.Msg = "添加成功!"; messageModel.Code = 200; messageModel.Success = true;
            }
            else
            {
                messageModel.Msg = "添加失败!"; messageModel.Code = 400; messageModel.Success = false;
            }
            return(Ok(messageModel));
        }
Пример #2
0
        public async Task <ActionResult <InfoResult <string> > > Updatenotice(AcNoticeDtos acNoticeDtos)
        {
            var NewNotice = (await _IAcNoticeService.Search(u => u.Id == acNoticeDtos.Id)).FirstOrDefault();
            InfoResult <AcNoticeDtos> messageModel = new InfoResult <AcNoticeDtos>();

            if (NewNotice != null)
            {
                NewNotice.Title  = acNoticeDtos.Title;
                NewNotice.Detail = acNoticeDtos.Detail;
                return(await _IAcNoticeService.Edit(NewNotice) > 0 ? new InfoResult <string>("修改成功!") : new InfoResult <string>("修改失败!"));
            }
            return(Ok(messageModel));
        }
Пример #3
0
        public async Task <ActionResult <InfoResult <AcNoticeDtos> > > Deletenotice(AcNoticeDtos acNoticeDtos)
        {
            var data = await _IAcNoticeService.Delete(_mapper.Map <AcNotice>(acNoticeDtos));

            InfoResult <AcNoticeDtos> messageModel = new InfoResult <AcNoticeDtos>();

            if (data > 0)
            {
                messageModel.Code    = 200;
                messageModel.Success = true;
                messageModel.Msg     = "删除成功";
            }
            else
            {
                messageModel.Code    = 400;
                messageModel.Success = false;
                messageModel.Msg     = "删除失败!";
            }
            return(Ok(messageModel));
        }