public int AddNotice(ref CNotice aNotice) { LNoticeDataContext tmpNC = new LNoticeDataContext(); // CNotice tmpNotice = new CNotice(); // tmpNotice.theUniqueID = 0; TNotice tmpNotice = new TNotice(); tmpNotice.theNumber = 0; tmpNotice.theTitle = aNotice.theTitle; tmpNotice.theContent = aNotice.theContent; tmpNotice.theWriter = aNotice.theWriter; tmpNotice.theDate = DateTime.Now; // theNotices.Add(tmpNotice); tmpNC.TNotice.InsertOnSubmit(tmpNotice); tmpNC.SubmitChanges(); aNotice.theDate = DateTime.Now; return(1); }
public List <CNotice> GetBoard(int aNPage) { LNoticeDataContext tmpNC = new LNoticeDataContext(); Table <TNotice> tmpT = tmpNC.TNotice; IQueryable <TNotice> tmpQ; tmpQ = tmpT; IQueryable <TNotice> tmpR = tmpQ.OrderByDescending(x => x.theUniqueID).Skip((aNPage - 1) * theNPageSize).Take(theNPageSize); List <TNotice> tmpL = tmpR.ToList <TNotice>(); List <CNotice> resNList = new List <CNotice>(); foreach (TNotice iter in tmpL) { CNotice tmpA = new CNotice(); tmpA.theUniqueID = iter.theUniqueID; tmpA.theNumber = iter.theNumber; tmpA.theTitle = iter.theTitle; tmpA.theWriter = iter.theWriter; tmpA.theContent = iter.theContent; tmpA.theDate = iter.theDate; if (DateTime.Compare(iter.theDate, DateTime.Today.AddDays(-3)) > 0) { tmpA.bNew = 1; } else { tmpA.bNew = 0; } resNList.Add(tmpA); } return(resNList); }
public List <CNotice> GetNotices() { LNoticeDataContext tmpNC = new LNoticeDataContext(); // return (theNotices); IQueryable <TNotice> tmpR = tmpNC.TNotice.OrderByDescending(x => x.theUniqueID); List <TNotice> tmpL = tmpR.ToList <TNotice>(); List <CNotice> resNotices = new List <CNotice>(); foreach (TNotice iter in tmpL) { CNotice tmpNotice = new CNotice(); tmpNotice.theUniqueID = iter.theUniqueID; tmpNotice.theNumber = iter.theNumber; tmpNotice.theTitle = iter.theTitle; tmpNotice.theWriter = iter.theWriter; tmpNotice.theContent = iter.theContent; tmpNotice.theDate = iter.theDate; resNotices.Add(tmpNotice); } return(resNotices); }