예제 #1
0
        public bool Update(NewsViewRecordViewModel model)
        {
            var entity = uow.Set <NewsViewRecord>().Find(model.Id);

            if (entity == null)
            {
                return(false);
            }
            entity.StudentNO = model.StudentNO;
            entity.StudentId = model.StudentId;
            entity.NewsId    = model.NewsId;
            entity.NewsTitle = model.NewsTitle;
            uow.Commit();
            return(true);
        }
예제 #2
0
        public bool Add(NewsViewRecordViewModel model)
        {
            News news = uow.Set <News>().Find(model.NewsId);

            if (news == null)
            {
                return(false);
            }
            model.Id = Guid.NewGuid().ToString();
            NewsViewRecord entity = new NewsViewRecord();

            uow.Set <NewsViewRecord>().Add(entity);
            entity.Id        = model.Id;
            entity.StudentNO = model.StudentNO;
            entity.StudentId = model.StudentId;
            entity.NewsId    = model.NewsId;
            entity.NewsTitle = model.NewsTitle;
            entity.CreateAt  = DateTime.Now;
            news.ViewCount++;
            uow.Commit();
            return(true);
        }