//
 //Summary:
 //  This method is used to check Login details
 public User Login(string emailId, string password)
 {
     using (CollegeDBContext collegeDBContext = new CollegeDBContext())
     {
         return(collegeDBContext.User.Where(m => m.EmailId == emailId && m.Password == password).FirstOrDefault());
     }
 }
 //
 //Summary:
 //  Check User is already Exists or not.
 //Return:
 //  Return User Entity
 public User CheckExistUser(User user)
 {
     using (CollegeDBContext collegeDBContext = new CollegeDBContext())
     {
         return(collegeDBContext.User.Where(m => m.EmailId == user.EmailId).FirstOrDefault());
     }
 }
 //
 //Summary:
 //  This method is to get College using code from database
 //Return:
 //  Returns College object
 public College GetCollegeByCode(string code)
 {
     using (CollegeDBContext collegeDBContext = new CollegeDBContext())
     {
         return(collegeDBContext.Colleges.Find(code));
     }
 }
 //
 //Summary:
 //  This method is to get college from database
 //Return:
 //  returns List of  Colleges
 public IEnumerable <College> GetColleges()
 {
     using (CollegeDBContext collegeDBContext = new CollegeDBContext())
     {
         return(collegeDBContext.Colleges.ToList());
     }
 }
 //
 //Summary:
 // Check Exists College in Db
 //Return:
 // Returns College Entity
 public College CheckExistCollege(College college)
 {
     using (CollegeDBContext collegeDBContext = new CollegeDBContext())
     {
         return(collegeDBContext.Colleges.Where(c => c.CollegeCode == college.CollegeCode || c.CollegeName == college.CollegeName || c.CollegeWebsite == college.CollegeWebsite).FirstOrDefault());
     }
 }
 //
 //Summary:
 //  This method is used register user details to the database
 public void SignUp(User user)
 {
     using (CollegeDBContext collegeDBContext = new CollegeDBContext())
     {
         collegeDBContext.User.Add(user);
         collegeDBContext.SaveChanges();
     }
 }
 //
 //Summary:
 //  This method is to delete college
 public void DeleteCollege(string code)
 {
     using (CollegeDBContext collegeDBContext = new CollegeDBContext())
     {
         SqlParameter collegeCode = new SqlParameter("@CollegeCode", code);
         collegeDBContext.Database.ExecuteSqlCommand("College_Delete @CollegeCode", collegeCode);
         //College college = GetCollegeByCode(code);
         //collegeDBContext.Colleges.Remove(college);
         //collegeDBContext.SaveChanges();
     }
 }
 //
 //Summary:
 //  This method is to Update college to database
 public void UpdateCollege(College college)
 {
     using (CollegeDBContext collegeDBContext = new CollegeDBContext())
     {
         SqlParameter collegeCode    = new SqlParameter("@CollegeCode", college.CollegeCode);
         SqlParameter collegeName    = new SqlParameter("@CollegeName", college.CollegeName);
         SqlParameter collegeWebsite = new SqlParameter("@CollegeWebsite", college.CollegeWebsite);
         collegeDBContext.Database.ExecuteSqlCommand("College_Update @CollegeCode, @CollegeName, @CollegeWebsite", collegeCode, collegeName, collegeWebsite);
         //collegeDBContext.Entry(college).State = EntityState.Modified;
         //collegeDBContext.SaveChanges();
     }
 }
 //
 //Summary:
 //  This method is to Add college to database
 public void AddCollege(College college)
 {
     using (CollegeDBContext collegeDBContext = new CollegeDBContext())
     {
         SqlParameter collegeCode    = new SqlParameter("@CollegeCode", college.CollegeCode);
         SqlParameter collegeName    = new SqlParameter("@CollegeName", college.CollegeName);
         SqlParameter collegeWebsite = new SqlParameter("@CollegeWebsite", college.CollegeWebsite);
         collegeDBContext.Database.ExecuteSqlCommand("College_Insert @CollegeCode, @CollegeName, @CollegeWebsite", collegeCode, collegeName, collegeWebsite);
         //collegeDBContext.Colleges.Add(college);
         //collegeDBContext.SaveChanges();
     }
 }