Ejemplo n.º 1
0
 public void Add(long PaperId, long SubjectId, long StuId, string Answer, int Score)
 {
     using (MyDbContext ctx = new MyDbContext())
     {
         StuPaperShowEntity ef = new StuPaperShowEntity();
         ef.Answer    = Answer;
         ef.PaperId   = PaperId;
         ef.Score     = Score;
         ef.StuId     = StuId;
         ef.SubjectId = SubjectId;
         ctx.StuPaperShows.Add(ef);
         ctx.SaveChanges();
         if (ef.Id < 0)
         {
             throw new Exception("添加失败");
         }
     }
 }
Ejemplo n.º 2
0
        public StuPaperShowDTO ToDTO(StuPaperShowEntity ef)
        {
            StuPaperShowDTO dto = new StuPaperShowDTO();

            dto.Id      = ef.Id;
            dto.PaperId = ef.PaperId;
            dto.Score   = ef.Score;
            dto.StuId   = ef.StuId;

            var studentdata = _studentService.GetByUserId(ef.StuId);

            if (studentdata != null)
            {
                dto.StuName = studentdata.UserName;
            }
            var subjectdata = _subjectService.GetById(ef.SubjectId);

            if (subjectdata == null)
            {
                dto.Subjects = subjectdata;
            }
            return(dto);
        }