public bool Cancel(ClassActionParam model)
 {
     try
     {
         UnitOfWork uow = new UnitOfWork();
         Class      cls = uow.Classes.Get(a => a.ClassID == model.ClassId).FirstOrDefault();
         if (cls != null)
         {
             cls.Status       = (int)ClassStatus.Cancelled;
             cls.CancelReason = model.CancelReason;
             cls.UpdateDate   = DateTime.Now;
         }
         uow.Classes.Update(cls);
         uow.Save();
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
 public string Join(ClassActionParam model)
 {
     try
     {
         string        userId        = Session["UserId"].ToString();
         UnitOfWork    uow           = new UnitOfWork();
         Class         classs        = uow.Classes.Get(a => a.ClassID == model.ClassId).FirstOrDefault();
         StudentCredit studentCredit = uow.StudentCredits.Get(a => a.StudentID == userId).FirstOrDefault();
         if (classs != null && studentCredit != null)
         {
             if (studentCredit.TotalCredits > classs.Duration)
             {
                 StudentClass studentClass = new StudentClass
                 {
                     ClassID     = model.ClassId,
                     JoiningDate = DateTime.Now,
                     StudentID   = Session["UserId"].ToString(),
                     Status      = (int)ClassJoinStatus.Pending
                 };
                 uow.StudentClasses.Insert(studentClass);
                 uow.Save();
                 Common.AddNotification(Session["UserName"] + " requested to join your class " + classs.Title, "", studentClass.StudentID, classs.TeacherID, "/tutor/requests?c=" + classs.ClassID, (int)NotificationType.Class);
                 return("success");
             }
             else
             {
                 return("no-balance");
             }
         }
         return("no-balance");
     }
     catch (Exception ex)
     {
         return("error");
     }
 }