示例#1
0
        public ActionResult Add(NoticeView model)
        {
            ResultView <int> view = new ResultView <int>();

            if (string.IsNullOrEmpty(model.Content))
            {
                view.Flag    = false;
                view.Message = "内容不能为空";
                return(Json(view));
            }
            if (string.IsNullOrEmpty(model.Title))
            {
                view.Flag    = false;
                view.Message = "标题不能为空";
                return(Json(view));
            }
            if (model.WayOfRelease == null)
            {
                view.Flag    = false;
                view.Message = "发布途径不能为空";
                return(Json(view));
            }
            Result <int> result = new Result <int>();

            using (BusinessClientProxy proxy = new BusinessClientProxy(ProxyEx(Request)))
            {
                result = proxy.AddNotice(model);
            }
            return(Json(result.ToResultView()));
        }
示例#2
0
        public ActionResult GetNoticeListData(int page)
        {
            int count = 6;//单页显示数量
            IQueryable <Notice> notices = db.Notices.OrderByDescending(a => a.Id).Skip((page - 1) * count).Take(count);
            List <NoticeView>   models  = new List <NoticeView>();

            foreach (Notice n in notices)
            {
                NoticeView nv = new NoticeView
                {
                    Id         = n.Id,
                    type       = n.type,
                    Title1     = n.Title1,
                    Content    = n.Content,
                    CreateDate = n.CreateDate.ToLongDateString(),
                };
                models.Add(nv);
            }
            PageDataModel dataModel = new PageDataModel()
            {
                code  = 0,
                msg   = "",
                count = (int)Math.Ceiling((double)db.Notices.Count() / count),
                data  = models.AsQueryable()
            };

            return(Json(dataModel, JsonRequestBehavior.AllowGet));
        }
示例#3
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,NoticeId,StudentId")] NoticeView noticeView)
        {
            if (id != noticeView.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(noticeView);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!NoticeViewExists(noticeView.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["NoticeId"]  = new SelectList(_context.Notice, "Id", "Id", noticeView.NoticeId);
            ViewData["StudentId"] = new SelectList(_context.Set <Student>(), "Id", "Id", noticeView.StudentId);
            return(View(noticeView));
        }
示例#4
0
        public ActionResult AddNotice()
        {
            NoticeView notice = new NoticeView();

            notice.Categories = repository.Categories.Select(p => new SelectListItem {
                Text = p.CategoryName, Value = p.CategoryID.ToString()
            });
            notice.Cities = repository.Cities.Select(p => new SelectListItem {
                Text = p.CityName, Value = p.CityId.ToString()
            });

            return(View(notice));
        }
示例#5
0
        public async Task <IActionResult> Create([Bind("Id,NoticeId,StudentId")] NoticeView noticeView)
        {
            if (ModelState.IsValid)
            {
                _context.Add(noticeView);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["NoticeId"]  = new SelectList(_context.Notice, "Id", "Id", noticeView.NoticeId);
            ViewData["StudentId"] = new SelectList(_context.Set <Student>(), "Id", "Id", noticeView.StudentId);
            return(View(noticeView));
        }
示例#6
0
        public ActionResult AddNotice(NoticeView model)
        {
            UserNumber tuser = db.UserNumbers.Find(User.Identity.Name);
            Notice     nn    = new Notice();

            nn.Content    = model.Content;
            nn.Title1     = model.Title1;
            nn.Title2     = model.Title2;
            nn.type       = model.type;
            nn.User       = tuser;
            nn.CreateDate = DateTime.Now;
            db.Notices.Add(nn);
            db.SaveChanges();
            return(RedirectToAction("Notice"));
        }
示例#7
0
        public ActionResult AddNotice(NoticeView notice, HttpPostedFileBase image)
        {
            if (ModelState.IsValid)
            {
                //if(image != null)
                //{
                //    noticeForSave.ImageData = new byte[image.ContentLength];
                //    noticeForSave.ImageMimeType = image.ContentType;
                //    image.InputStream.Read(notice.ImageData, 0, image.ContentLength);
                //}

                Mapper.Initialize(cfg => cfg.CreateMap <NoticeView, Notice>()
                                  .ForMember("DateCreation", opt => opt.UseValue(DateTime.Now)));
                Notice noticeForSave = Mapper.Map <NoticeView, Notice>(notice);

                if (image != null)
                {
                    noticeForSave.ImageData     = new byte[image.ContentLength];
                    noticeForSave.ImageMimeType = image.ContentType;
                    image.InputStream.Read(noticeForSave.ImageData, 0, image.ContentLength);
                }

                //noticeForSave = notice.Notice;
                //noticeForSave.AuthorName = notice.AuthorName;
                //noticeForSave.CategoryID = notice.CategoryID;
                //noticeForSave.CityId = notice.CityId;
                //noticeForSave.Content = notice.Content;
                //noticeForSave.Email = notice.Email;
                //noticeForSave.Phone = notice.Phone;
                //noticeForSave.Theme = notice.Theme;
                //noticeForSave.DateCreation = DateTime.Now;
                //noticeForSave.IsLost.
                repository.Add(noticeForSave);
                repository.SaveNotice();

                return(RedirectToAction("List"));
            }

            notice.Categories = repository.Categories.Select(p => new SelectListItem {
                Text = p.CategoryName, Value = p.CategoryID.ToString()
            });
            notice.Cities = repository.Cities.Select(p => new SelectListItem {
                Text = p.CityName, Value = p.CityId.ToString()
            });
            return(View(notice));
        }
示例#8
0
        public async Task <IActionResult> Details(int?id)
        {
            if (User.IsInRole("student"))
            {
                //Write the notice viewed record
                var user = (from student in _context.Student
                            where student.StudentEmail.Equals(User.Identity.Name)
                            select student).FirstOrDefault();

                NoticeView view = new NoticeView();

                view.StudentId = user.Id;
                view.NoticeId  = id.GetValueOrDefault();
                var noticeViews = (from views in _context.NoticeView
                                   where views.StudentId == user.Id && views.NoticeId == id.GetValueOrDefault()
                                   select views).ToList();

                if (noticeViews.Count == 0)
                {
                    _context.Add(view);
                    await _context.SaveChangesAsync();
                }
            }


            if (id == null)
            {
                return(NotFound());
            }

            var notice = await _context.Notice
                         .FirstOrDefaultAsync(m => m.Id == id);

            if (notice == null)
            {
                return(NotFound());
            }

            return(View(notice));
        }
示例#9
0
        /// <summary>
        /// 通过通知单号来获取对应通知单数据
        /// </summary>
        /// <param name="Notice_Id"></param>
        /// <returns></returns>
        public Notice_A13dot1 getNoticeForA13dot1ByNI(string Notice_Id)
        {
            NoticeView Notice = new NoticeView();

            return(Notice.getNoticeByNI(Notice_Id));
        }
示例#10
0
        /// <summary>
        /// 删除功能,即该库中状态为2
        /// </summary>
        /// <param name="Notice_Id"></param>
        /// <returns></returns>
        public string removeNoticeForA13dot1(string Notice_Id)
        {
            NoticeView Notice = new NoticeView();

            return(Notice.RemoveNoticeState(Notice_Id));
        }
示例#11
0
        /// <summary>
        /// 生成13.1的工作流,同时修改状态为1,传入操作人和操作时间
        /// </summary>
        /// <param name="username"></param>
        /// <param name="opertime"></param>
        /// <param name="Notice_Id"></param>
        /// <returns></returns>
        public string modifyNoticeForA13dot1(string username, string opertime, string Notice_Id)
        {
            NoticeView Notice = new NoticeView();

            return(Notice.ModifyNoticeState(username, opertime, Notice_Id));
        }
示例#12
0
        /// <summary>
        /// 适用于流程A13.1 获取状态为1即待处理的通知单(现场工程师提交的)
        /// </summary>
        /// <returns></returns>
        public List <Notice_A13dot1> getNoticeForA13dot1Uncomp()
        {
            NoticeView Notice = new NoticeView();

            return(Notice.GetNotice_A13dot1Uncomp());
        }
示例#13
0
 ///<summary>
 ///添加:
 ///</summary>
 ///<param name="model">要添加的model</param>
 ///<returns>受影响的行数</returns>
 public Result <int> AddNotice(NoticeView model)
 {
     return(base.Channel.AddNotice(model));
 }