Example #1
0
 public int Delete(int ID)
 {
     try
     {
         tblSemester tb = _db.tblSemesters.Where(s => s.Semester_Id == ID).FirstOrDefault();
         _db.tblSemesters.Remove(tb);
         return(_db.SaveChanges());
     }
     catch (Exception Error)
     {
         throw Error;
     }
 }
Example #2
0
        public int Update(SemesterViewModel svm)
        {
            tblSemester tb           = _db.tblSemesters.Where(s => s.Semester_Id == svm.Id).FirstOrDefault();
            var         semesterName = tb.Semester_Name;

            tb.Semester_Name = svm.Semester_Name;
            _db.SaveChanges();
            tblMainLog tml       = new tblMainLog();
            var        principal = System.Security.Claims.ClaimsPrincipal.Current;
            string     Name      = principal.FindFirst(ClaimsIdentity.DefaultNameClaimType).Value;

            str             = "Semester Name Updated from '" + semesterName + "' " + "to '" + svm.Semester_Name + "' " + "by Admin";
            tml.Description = str;
            tml.AdminName   = Name;
            tml.Date        = System.DateTime.Now;
            tml.EntityId    = 7;
            tml.ItemId      = tb.Semester_Id;
            _db.tblMainLogs.Add(tml);
            return(_db.SaveChanges());
        }
Example #3
0
        public int Add(SemesterViewModel svm)
        {
            tblSemester tb = new tblSemester();

            tb.Semester_Name = svm.Semester_Name;
            _db.tblSemesters.Add(tb);
            _db.SaveChanges();
            tblMainLog tml       = new tblMainLog();
            var        principal = System.Security.Claims.ClaimsPrincipal.Current;
            string     Name      = principal.FindFirst(ClaimsIdentity.DefaultNameClaimType).Value;

            str             = "New Semester '" + svm.Semester_Name + "' " + "Added by Admin";
            tml.Description = str;
            tml.AdminName   = Name;
            tml.Date        = System.DateTime.Now;
            tml.EntityId    = 7;
            tml.ItemId      = tb.Semester_Id;
            _db.tblMainLogs.Add(tml);
            return(_db.SaveChanges());
        }