public JsonResult IsCourseExist(int Id)
        {
            List <CourseAssign> teachers = courseBll.GetAssignCourses();
            bool isExist = teachers.FirstOrDefault(u => u.CourseId.Equals(Id)) != null;

            return(Json(isExist, JsonRequestBehavior.AllowGet));
        }
Пример #2
0
        //protected override ValidationResult IsValid(object value, ValidationContext validationContext)
        //{
        //    List<CourseAssign> teachers = courseBll.GetAssignCourses();
        //    bool isExist = teachers.FirstOrDefault(u => u.CourseId.Equals(value)) != null;

        //    var assignCourse = (CourseAssign) validationContext.ObjectInstance;
        //    if (isExist)
        //    {
        //        return new ValidationResult("Course Already assign");
        //    }
        //    else
        //    {
        //        return  ValidationResult.Success;
        //    }
        //}

        public override bool IsValid(object value)
        {
            List <CourseAssign> teachers = courseBll.GetAssignCourses();
            bool isExist = teachers.FirstOrDefault(u => u.CourseId.Equals(value)) != null;

            return(!isExist);
        }