public static List <SelectListItem> drpCourseLevel()
 {
     using (IN705_201802_arulr1Entities1 entity = new IN705_201802_arulr1Entities1())
     {
         var drpData = (from item in entity.CourseLevels
                        select new SelectListItem
         {
             Text = item.LevelName.ToString(),
             Value = item.CourseLevelID.ToString(),
         }).ToList();
         drpData.Insert(0, new SelectListItem {
             Text = "-- Select Level --", Value = ""
         });
         return(drpData);
     }
 }
 public static List <SelectListItem> drpTutor()
 {
     using (IN705_201802_arulr1Entities1 entity = new IN705_201802_arulr1Entities1())
     {
         var drpData = (from item in entity.Tutors
                        select new SelectListItem
         {
             Text = item.User.FirstName.ToString() + " " + item.User.LastName.ToString(),
             Value = item.TutorID.ToString(),
         }).ToList();
         drpData.Insert(0, new SelectListItem {
             Text = "-- Select Tutor --", Value = ""
         });
         return(drpData);
     }
 }
 public static List <SelectListItem> drpStaff()
 {
     using (IN705_201802_arulr1Entities1 entity = new IN705_201802_arulr1Entities1())
     {
         var drpData = (from item in entity.Users where item.UserRoleID == 2 || item.UserRoleID == 3
                        select new SelectListItem
         {
             Text = item.FirstName.ToString() + " " + item.LastName.ToString(),
             Value = item.UserID.ToString(),
         }).ToList();
         drpData.Insert(0, new SelectListItem {
             Text = "-- Select staff --", Value = ""
         });
         return(drpData);
     }
 }
 public static List <SelectListItem> drpPaymentStatus()
 {
     using (IN705_201802_arulr1Entities1 entity = new IN705_201802_arulr1Entities1())
     {
         var drpData = (from item in entity.PaymentStatus
                        select new SelectListItem
         {
             Text = item.StatusName.ToString(),
             Value = item.PaymentStatus.ToString(),
         }).ToList();
         drpData.Insert(0, new SelectListItem {
             Text = "-- Select Payment status --", Value = ""
         });
         return(drpData);
     }
 }
 public static List <SelectListItem> drpInstrumentHire()
 {
     using (IN705_201802_arulr1Entities1 entity = new IN705_201802_arulr1Entities1())
     {
         var drpData = (from item in entity.InstrumentHires
                        select new SelectListItem
         {
             Text = item.Enrolment.Student.User.FirstName.ToString() + " " + item.Enrolment.Student.User.LastName.ToString() + " ( " + item.Enrolment.Lessonbatch.Name.ToString() + " )",
             Value = item.InstrumentHireId.ToString(),
         }).ToList();
         drpData.Insert(0, new SelectListItem {
             Text = "-- Select Hire --", Value = ""
         });
         return(drpData);
     }
 }
 public static List <SelectListItem> drpInstrument()
 {
     using (IN705_201802_arulr1Entities1 entity = new IN705_201802_arulr1Entities1())
     {
         var drpData = (from item in entity.Instruments
                        select new SelectListItem
         {
             Text = item.Name.ToString(),
             Value = item.InstrumentID.ToString(),
         }).ToList();
         drpData.Insert(0, new SelectListItem {
             Text = "-- Select Instrument --", Value = ""
         });
         return(drpData);
     }
 }
 public static List <SelectListItem> drpUserRole()
 {
     using (IN705_201802_arulr1Entities1 entity = new IN705_201802_arulr1Entities1())
     {
         var drpData = (from item in entity.UserRoles
                        select new SelectListItem
         {
             Text = item.Role.ToString(),
             Value = item.UserRoleID.ToString(),
         }).ToList();
         drpData.Insert(0, new SelectListItem {
             Text = "-- Select Role --", Value = ""
         });
         return(drpData);
     }
 }
 public static List <SelectListItem> drpLesson()
 {
     using (IN705_201802_arulr1Entities1 entity = new IN705_201802_arulr1Entities1())
     {
         var drpData = (from item in entity.Lessons
                        select new SelectListItem
         {
             Text = item.Name.ToString() + " ( " + item.Instrument.Name + " - " + item.CourseLevel.LevelName.ToString() + " )",
             Value = item.LessonID.ToString(),
         }).ToList();
         drpData.Insert(0, new SelectListItem {
             Text = "-- Select Lesson --", Value = ""
         });
         return(drpData);
     }
 }
        protected override ValidationResult IsValid(object value, ValidationContext validationContext)
        {
            ValidationResult validationResult = ValidationResult.Success;

            try
            {
                var otherPropertyInfo = validationContext.ObjectType.GetProperty(this.otherPropertyName);
                if (otherPropertyInfo.PropertyType.Equals(new Int32().GetType()))
                {
                    int EnrolmentID        = (int)value;
                    int InstrumentAssertID = (int)otherPropertyInfo.GetValue(validationContext.ObjectInstance, null);

                    using (IN705_201802_arulr1Entities1 entity = new IN705_201802_arulr1Entities1())
                    {
                        Enrolment        enrolment        = entity.Enrolments.Where(f => f.EnrolmentID == EnrolmentID).FirstOrDefault();
                        InstrumentAssert instrumentAssert = entity.InstrumentAsserts.Where(f => f.InstrumentAssertID == InstrumentAssertID).FirstOrDefault();
                        InstrumentHire   instrumentHire   = entity.InstrumentHires.Where(f => f.EnrolmentID == enrolment.EnrolmentID && f.InstrumentAssertID == instrumentAssert.InstrumentAssertID).FirstOrDefault();
                        if (enrolment.Lessonbatch.Lesson.InstrumentID == instrumentAssert.InstrumentID && instrumentHire == null)
                        {
                            return(ValidationResult.Success);
                        }
                        else if (enrolment.Lessonbatch.Lesson.InstrumentID != instrumentAssert.InstrumentID)
                        {
                            return(new ValidationResult("Enrolment can't hire this instrument."));
                        }
                        else if (instrumentHire != null)
                        {
                            return(new ValidationResult("Enrolment currently has an instrument hired."));
                        }
                        else
                        {
                            return(new ValidationResult("Enrolment can't hire this instrument and currently has an instrument hired."));
                        }
                    }
                }
                else
                {
                    validationResult = new ValidationResult("An error occurred while validating the property.");
                }
            }
            catch (Exception)
            {
                return(new ValidationResult("Enrolment can't hire this instrument."));
            }

            return(validationResult);
        }
        public static List <SelectListItem> drpProgram()
        {
            using (IN705_201802_arulr1Entities1 entity = new IN705_201802_arulr1Entities1())
            {
                var drpData = (from item in entity.Performances
                               select new SelectListItem
                {
                    Text = item.Name.ToString(),
                    Value = item.PerformanceID.ToString(),
                }).ToList();

                drpData.Insert(0, new SelectListItem {
                    Text = "-- Select Program --", Value = ""
                });
                return(drpData);
            }
        }
        protected override ValidationResult IsValid(object value, ValidationContext validationContext)
        {
            ValidationResult validationResult = ValidationResult.Success;

            try
            {
                var otherPropertyInfo     = validationContext.ObjectType.GetProperty(this.otherPropertyName);
                var enrolmentPropertyInfo = validationContext.ObjectType.GetProperty(this.EnrolmentPropertyName);
                if (otherPropertyInfo.PropertyType.Equals(new Int32().GetType()))
                {
                    int LessonBatchID = (int)value;
                    int studentID     = (int)otherPropertyInfo.GetValue(validationContext.ObjectInstance, null);
                    int enromlentD    = (int)enrolmentPropertyInfo.GetValue(validationContext.ObjectInstance, null);

                    using (IN705_201802_arulr1Entities1 entity = new IN705_201802_arulr1Entities1())
                    {
                        Enrolment enrolment = entity.Enrolments.Where(f => f.StudentID == studentID && f.LessonBatchID == LessonBatchID).FirstOrDefault();
                        if (enrolment == null)
                        {
                            return(ValidationResult.Success);
                        }
                        else if (enrolment.EnrolmentID == enromlentD)
                        {
                            return(ValidationResult.Success);
                        }
                        else
                        {
                            return(new ValidationResult("Student is already enrolled in this lesson."));
                        }
                    }
                }
                else
                {
                    validationResult = new ValidationResult("An error occurred while validating the property.");
                }
            }
            catch (Exception)
            {
                return(new ValidationResult("Student is already enrolled in this lesson."));
            }

            return(validationResult);
        }
        protected override ValidationResult IsValid(object value, ValidationContext validationContext)
        {
            ValidationResult validationResult = ValidationResult.Success;

            try
            {
                var otherPropertyInfo = validationContext.ObjectType.GetProperty(this.otherPropertyName);
                if (otherPropertyInfo.PropertyType.Equals(new Int32().GetType()))
                {
                    string email  = (string)value;
                    int    userID = (int)otherPropertyInfo.GetValue(validationContext.ObjectInstance, null);

                    using (IN705_201802_arulr1Entities1 entity = new IN705_201802_arulr1Entities1())
                    {
                        User datasetUser = entity.Users.Where(f => f.Email == email).FirstOrDefault();
                        if (datasetUser.UserID == userID)
                        {
                            return(ValidationResult.Success);
                        }
                        else if (datasetUser == null)
                        {
                            return(ValidationResult.Success);
                        }
                        else
                        {
                            return(new ValidationResult("Email address alrady exists."));
                        }
                    }
                }
                else
                {
                    validationResult = new ValidationResult("An error occurred while validating the property.");
                }
            }
            catch (Exception)
            {
                return(new ValidationResult("Email address alrady exists."));
            }

            return(validationResult);
        }
        protected override ValidationResult IsValid(object value, ValidationContext validationContext)
        {
            ValidationResult validationResult = ValidationResult.Success;

            try
            {
                var otherPropertyInfo = validationContext.ObjectType.GetProperty(this.otherPropertyName);
                if (otherPropertyInfo.PropertyType.Equals(new Int32().GetType()))
                {
                    int tutorID  = (int)value;
                    int lessonID = (int)otherPropertyInfo.GetValue(validationContext.ObjectInstance, null);

                    using (IN705_201802_arulr1Entities1 entity = new IN705_201802_arulr1Entities1())
                    {
                        Tutor  tutor  = entity.Tutors.Where(f => f.TutorID == tutorID).FirstOrDefault();
                        Lesson lesson = entity.Lessons.Where(f => f.LessonID == lessonID).FirstOrDefault();
                        var    skill  = entity.InstumentLevels.Where(f => f.UserID == tutor.UserID && f.CourseLevelID > lesson.CourseLevelID && f.InstrumentID == lesson.InstrumentID).ToList();
                        if (skill.Count > 0)
                        {
                            return(ValidationResult.Success);
                        }
                        else
                        {
                            return(new ValidationResult("Levels are conflicting with course and tutor."));
                        }
                    }
                }
                else
                {
                    validationResult = new ValidationResult("An error occurred while validating the property.");
                }
            }
            catch (Exception)
            {
                return(new ValidationResult("Levels are conflicting with course and tutor."));
            }

            return(validationResult);
        }
 protected override ValidationResult IsValid(object value, ValidationContext validationContext)
 {
     try
     {
         using (IN705_201802_arulr1Entities1 entity = new IN705_201802_arulr1Entities1())
         {
             var lessonbatch = entity.Lessonbatches.Where(f => f.LessonBatchID == (Int32)value).ToList();
             if (lessonbatch.Count < 16)
             {
                 return(ValidationResult.Success);
             }
             else
             {
                 return(new ValidationResult("Group size has reached the maximum."));
             }
         }
     }
     catch
     {
         return(new ValidationResult("Group size has reached the maximum."));
     }
 }
 protected override ValidationResult IsValid(object value, ValidationContext validationContext)
 {
     try
     {
         using (IN705_201802_arulr1Entities1 entity = new IN705_201802_arulr1Entities1())
         {
             InstumentService instumentService = entity.InstumentServices.Where(f => f.InstrumentHireId == (Int32)value).FirstOrDefault();
             if (instumentService == null)
             {
                 return(ValidationResult.Success);
             }
             else
             {
                 return(new ValidationResult("Instrument is being serviced."));
             }
         }
     }
     catch
     {
         return(new ValidationResult("Instrument is being serviced."));
     }
 }
 public CourseController()
 {
     entities = new IN705_201802_arulr1Entities1();
 }
Esempio n. 17
0
 public MasterController()
 {
     entities = new IN705_201802_arulr1Entities1();
 }
Esempio n. 18
0
 public OrchestraController()
 {
     entities = new IN705_201802_arulr1Entities1();
 }
Esempio n. 19
0
 public AdminController()
 {
     entities = new IN705_201802_arulr1Entities1();
 }