// // GET: /Notice/Create public ActionResult Create() { if (HttpContext.Session["UserId"] == null) { return RedirectToAction("Login", "Login"); } NoticeViewModel noticeModel = new NoticeViewModel(); noticeModel.publisherList = dropRepo.ApproverDropDown(); return View(noticeModel); }
public NoticeViewModel noticeDetails(int noticeId) { var singleNotice = entity.tblNotice1.Where(x => x.noticeId == noticeId).SingleOrDefault(); NoticeViewModel noticeModel = new NoticeViewModel() { noticeId=singleNotice.noticeId, noticeDate=singleNotice.Date, noticeontent=singleNotice.noticeContent, publisherId=singleNotice.publisherId, Publisher=singleNotice.tblApprover.approverName }; return noticeModel; }
public void addNotice(NoticeViewModel modelObj) { tblNotice1 newNotice = new tblNotice1() { noticeId=modelObj.noticeId, publisherId=modelObj.publisherId, Date=modelObj.noticeDate, noticeContent=modelObj.noticeontent, }; entity.tblNotice1.Add(newNotice); entity.SaveChanges(); }
public ActionResult Create(NoticeViewModel noticeModel) { if (HttpContext.Session["UserId"] == null) { return RedirectToAction("Login", "Login"); } try { // TODO: Add insert logic here noticeServ.addNotice(noticeModel); return RedirectToAction("Index","Home"); } catch { return View(); } }
public List<NoticeViewModel> NoticeList() { List<NoticeViewModel> noticeListtotal = new List<NoticeViewModel>(); var noticefromDb = entity.tblNotice1.ToList(); foreach(var noticeItem in noticefromDb) { NoticeViewModel noticeModel = new NoticeViewModel() { noticeId=noticeItem.noticeId, noticeontent=noticeItem.noticeContent, noticeDate=noticeItem.Date, publisherId=noticeItem.publisherId, Publisher=noticeItem.tblApprover.approverName }; noticeListtotal.Add(noticeModel); } return noticeListtotal; }