Exemple #1
0
 public void AddPaper(IPaper dataPaper)
 {
     try
     {
         using (BytepadDBEntities db = new BytepadDBEntities())
         {
             tblPaper dataTblPaper = new tblPaper
             {
                 AdminId      = 1,
                 SessionId    = dataPaper.SessionId,
                 SubjectId    = dataPaper.SubjectId,
                 ExamTypeId   = dataPaper.ExamTypeId,
                 SemesterType = dataPaper.SemesterType.ToString(),
                 PaperType    = dataPaper.PaperType,
                 FileUrl      = dataPaper.FileUrl
             };
             db.tblPapers.Add(dataTblPaper);
             db.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         string error = ex.ToString();
     }
 }
Exemple #2
0
 public void updateLastAddPaperTime()
 {
     using (BytepadDBEntities db = new BytepadDBEntities())
     {
         tblVersion temp = db.tblVersions.FirstOrDefault(data => data.ID == 1);
         if (temp == null)
         {
             temp    = new tblVersion();
             temp.ID = 1;
             temp.LastAddPaperTime = DateTime.Now;
             db.tblVersions.Add(temp);
             db.SaveChanges();
         }
         else
         {
             temp.LastAddPaperTime = DateTime.Now;
             db.SaveChanges();
         }
     }
 }
Exemple #3
0
 public void DeletePaperByID(int id)
 {
     using (BytepadDBEntities db = new BytepadDBEntities())
     {
         tblPaper tempPaper = new tblPaper();
         tempPaper = db.tblPapers.First(data => data.Id == id);
         string physicalPathDeleted = System.Web.HttpContext.Current.Server.MapPath("~\\" + ("Papers") + "/" + tempPaper.FileUrl);
         if (System.IO.File.Exists(physicalPathDeleted))
         {
             System.IO.File.Delete(physicalPathDeleted);
         }
         db.tblPapers.Remove(tempPaper);
         db.SaveChanges();
     }
 }
Exemple #4
0
 public void RemovePaperBySession(int sessionId)
 {
     using (BytepadDBEntities db = new BytepadDBEntities())
     {
         var papers = db.tblPapers.Where(x => x.SessionId == sessionId).ToList();
         foreach (var paper in papers)
         {
             string physicalPathDeleted = System.Web.HttpContext.Current.Server.MapPath("~\\" + ("Papers") + "/" + paper.FileUrl);
             if (System.IO.File.Exists(physicalPathDeleted))
             {
                 System.IO.File.Delete(physicalPathDeleted);
             }
         }
         db.tblPapers.RemoveRange(papers);
         db.SaveChanges();
     }
 }
Exemple #5
0
        public int AddSubjects(ISubject dataSubject)
        {
            tblSubject dataTblSubject = new tblSubject();

            try
            {
                using (BytepadDBEntities db = new BytepadDBEntities())
                {
                    dataTblSubject.SubjectName = dataSubject.SubjectName;
                    db.tblSubjects.Add(dataTblSubject);
                    db.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                string error = ex.ToString();
            }
            return(dataTblSubject.Id);
        }