using ACLib.P2.AppContext;
|
|
using ACLib.P2.AppContext.Models;
|
|
|
|
namespace ACLib.P2.v01.Controllers
|
|
{
|
|
/// <summary>
|
|
/// Interface Definition
|
|
/// </summary>
|
|
public interface IStudentManagerP2
|
|
{
|
|
|
|
#region Student Information
|
|
|
|
AC_Clients GetClient(string clientName);
|
|
IEnumerable<AC_Clients> GetClientById(int? clientId);
|
|
IEnumerable<AC_StudentAccommodationTerms> GetStudentAccommodationTerms(int? appid);
|
|
|
|
/*
|
|
int GetApplicationIDByStudentID(string studentid);
|
|
IEnumerable<AC_StudentAccommodations> GetStudentAccommodations(int appid);
|
|
IEnumerable<AC_StudentAppeals> GetStudentAppeals(int appid);
|
|
IEnumerable<AC_StudentLeaves> AC_StudentLeaves(int appid);
|
|
IEnumerable<AC_StudentComplains> AC_StudentComplains(int appid);
|
|
IEnumerable<AC_StudentExamDeferrals> GetStudentExamDeferrals(int appid);
|
|
IEnumerable<AC_StudentNonAcademicMisconducts> GetStudentNonAcademicMisconducts(int appid);
|
|
IEnumerable<AC_Consellings> GetStudentConsellings(int appid);
|
|
float GetMyCredits(int appid);
|
|
IEnumerable<int> GetStudentsWithCreditsOver(float totalcredits);
|
|
*/
|
|
#endregion
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// Interface Implementation
|
|
/// </summary>
|
|
///
|
|
public class StudentManagerP2 : IStudentManagerP2
|
|
{
|
|
string constring;
|
|
private readonly DatabaseContext _context;
|
|
|
|
public StudentManagerP2(DatabaseContext context)
|
|
{
|
|
this._context = context;
|
|
}
|
|
|
|
public AC_Clients GetClient(string clientName)
|
|
{
|
|
IEnumerable<AC_Clients> comtable;
|
|
comtable = this._context.AC_Clients.Where(u => u.ClientName == clientName);
|
|
return comtable.FirstOrDefault();
|
|
}
|
|
|
|
public IEnumerable<AC_Clients> GetClientById(int? clientId)
|
|
{
|
|
IEnumerable<AC_Clients> comtable;
|
|
comtable = _context.AC_Clients.Where(client => client.ID == clientId);
|
|
return comtable.ToList();
|
|
}
|
|
|
|
public IEnumerable<AC_StudentAccommodationTerms> GetStudentAccommodationTerms(int? appid)
|
|
{
|
|
IEnumerable<AC_StudentAccommodationTerms> comtab = Enumerable.Empty<AC_StudentAccommodationTerms>();
|
|
comtab = _context.AC_StudentAccommodationTerms.Where(u => u.AccommID == appid);
|
|
return comtab.ToList();
|
|
}
|
|
/*
|
|
|
|
public IEnumerable<AC_StudentAccommodations> GetStudentAccommodations(int appid)
|
|
{
|
|
IEnumerable<AC_StudentAccommodations> comtab = Enumerable.Empty<AC_StudentAccommodations>();
|
|
using (IDataContext ctx = DataContext.Instance())
|
|
{
|
|
comtab = ctx.ExecuteQuery<AC_StudentAccommodations>(System.Data.CommandType.Text, "select * from AC_StudentAccommodations where ApplicationID=" + appid);
|
|
}
|
|
|
|
foreach(AC_StudentAccommodations tx in comtab)
|
|
{
|
|
tx.AC_StudentAccommodationTerms = GetStudentAccommodationTerms(appid);
|
|
yield return tx;
|
|
}
|
|
}
|
|
|
|
public IEnumerable<AC_StudentAppeals> GetStudentAppeals(int appid)
|
|
{
|
|
IEnumerable<AC_StudentAppeals> comtab = Enumerable.Empty<AC_StudentAppeals>();
|
|
using (IDataContext ctx = DataContext.Instance())
|
|
{
|
|
comtab = ctx.ExecuteQuery<AC_StudentAppeals>(System.Data.CommandType.Text, "select * from AC_StudentAppeals where ApplicationID=" + appid);
|
|
}
|
|
|
|
return comtab;
|
|
}
|
|
|
|
public IEnumerable<AC_StudentLeaves> AC_StudentLeaves(int appid)
|
|
{
|
|
IEnumerable<AC_StudentLeaves> comtab = Enumerable.Empty<AC_StudentLeaves>();
|
|
using (IDataContext ctx = DataContext.Instance())
|
|
{
|
|
comtab = ctx.ExecuteQuery<AC_StudentLeaves>(System.Data.CommandType.Text, "select * from AC_StudentLeaves where ApplicationID=" + appid);
|
|
}
|
|
|
|
return comtab;
|
|
}
|
|
|
|
public IEnumerable<AC_StudentComplains> AC_StudentComplains(int appid)
|
|
{
|
|
IEnumerable<AC_StudentComplains> comtab = Enumerable.Empty<AC_StudentComplains>();
|
|
using (IDataContext ctx = DataContext.Instance())
|
|
{
|
|
comtab = ctx.ExecuteQuery<AC_StudentComplains>(System.Data.CommandType.Text, "select * from AC_StudentComplains where ApplicationID=" + appid);
|
|
}
|
|
|
|
return comtab;
|
|
}
|
|
|
|
public IEnumerable<AC_StudentExamDeferrals> GetStudentExamDeferrals(int appid)
|
|
{
|
|
IEnumerable<AC_StudentExamDeferrals> comtab = Enumerable.Empty<AC_StudentExamDeferrals>();
|
|
using (IDataContext ctx = DataContext.Instance())
|
|
{
|
|
comtab = ctx.ExecuteQuery<AC_StudentExamDeferrals>(System.Data.CommandType.Text, "select * from AC_StudentExamDeferrals where ApplicationID=" + appid);
|
|
}
|
|
|
|
return comtab;
|
|
}
|
|
|
|
public IEnumerable<AC_StudentNonAcademicMisconducts> GetStudentNonAcademicMisconducts(int appid)
|
|
{
|
|
IEnumerable<AC_StudentNonAcademicMisconducts> comtab = Enumerable.Empty<AC_StudentNonAcademicMisconducts>();
|
|
using (IDataContext ctx = DataContext.Instance())
|
|
{
|
|
comtab = ctx.ExecuteQuery<AC_StudentNonAcademicMisconducts>(System.Data.CommandType.Text, "select * from AC_StudentNonAcademicMisconducts where ApplicationID=" + appid);
|
|
}
|
|
|
|
return comtab;
|
|
}
|
|
|
|
public IEnumerable<AC_Consellings> GetStudentConsellings(int appid)
|
|
{
|
|
IEnumerable<AC_Consellings> comtab = Enumerable.Empty<AC_Consellings>();
|
|
using (IDataContext ctx = DataContext.Instance())
|
|
{
|
|
comtab = ctx.ExecuteQuery<AC_Consellings>(System.Data.CommandType.Text, "select * from AC_Consellings where ApplicationID=" + appid);
|
|
}
|
|
|
|
return comtab;
|
|
}
|
|
|
|
public float GetMyCredits(int appid)
|
|
{
|
|
float credits = 0;
|
|
string strsql = "select sum(credits) as finalcredits from ( " +
|
|
" select T1.ApplicationID , sum(T3.CourseCredit) as credits " +
|
|
" from AC_ApplicantCourse T1 join AC_ClassRun T2 on (T1.ClassID = T2.ClassID) join AC_Courses T3 on (T2.CourseNumber = T3.CourseNumber) " +
|
|
" where T3.CourseCredit > 0 and T1.Mark >= 50 and(T1.RepeatedCourse = 0 or RepeatedCourse is null) " +
|
|
" group by ApplicationID " +
|
|
" UNION " +
|
|
" select ApplicationID, sum(Credit) as credits from AC_AcademicCourseHistory group by ApplicationID " +
|
|
" ) G1 " +
|
|
" where ApplicationID = " + appid +
|
|
" group by G1.ApplicationID";
|
|
try
|
|
{
|
|
using (IDataContext ctx = DataContext.Instance())
|
|
{
|
|
credits = ctx.ExecuteScalar<float>(System.Data.CommandType.Text, strsql);
|
|
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return credits;
|
|
}
|
|
|
|
return credits;
|
|
}
|
|
|
|
|
|
public IEnumerable<int> GetStudentsWithCreditsOver(float totalcredits)
|
|
{
|
|
IEnumerable<int> appids = Enumerable.Empty<int>();
|
|
|
|
string strsql = "select ApplicationID from ( " +
|
|
"select ApplicationID, sum(credits) as finalcredits from ( " +
|
|
" select T1.ApplicationID , sum(T3.CourseCredit) as credits " +
|
|
" from AC_ApplicantCourse T1 join AC_ClassRun T2 on (T1.ClassID = T2.ClassID) join AC_Courses T3 on (T2.CourseNumber = T3.CourseNumber) " +
|
|
" where T3.CourseCredit > 0 and T1.Mark >= 50 and(T1.RepeatedCourse = 0 or RepeatedCourse is null) " +
|
|
" group by ApplicationID " +
|
|
" UNION " +
|
|
" select ApplicationID, sum(Credit) as credits from AC_AcademicCourseHistory group by ApplicationID " +
|
|
" ) G1 " +
|
|
" group by G1.ApplicationID" +
|
|
") G2 where finalcredits > =" + totalcredits;
|
|
try
|
|
{
|
|
using (IDataContext ctx = DataContext.Instance())
|
|
{
|
|
appids = ctx.ExecuteQuery<int>(System.Data.CommandType.Text, strsql);
|
|
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return appids;
|
|
}
|
|
|
|
return appids;
|
|
|
|
}
|
|
|
|
public int GetApplicationIDByStudentID(string studentid)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
*/
|
|
}
|
|
|
|
}
|