internal void UpdateFlightHours(DBClassesDataContext dbc) { IEnumerable <LessonTimeLog> lst = (from s in dbc.LessonTimeLogs where s.Student == StudentID && s.LESSONID == LessonID select s); foreach (LessonTimeLog compLog in lst) { // Now fill the hours.. HoursLogged = 0; GroundHoursLogged = 0; GroundHoursLogged += compLog.briefing; GroundHoursLogged += compLog.classvideo; GroundHoursLogged += compLog.debrief; HoursLogged += compLog.dualccday; HoursLogged += compLog.dualccnight; HoursLogged += compLog.duallocalday; HoursLogged += compLog.duallocalnight; GroundHoursLogged += compLog.exams; HoursLogged += compLog.soloccday; HoursLogged += compLog.soloccnight; HoursLogged += compLog.sololocalday; HoursLogged += compLog.sololocalnight; } }
/// <summary> /// See all the achievements that are unlocked by this task. if they arent already conferred, confer them /// Recalculate rewards unlocked by the achievement, if they arent already conferred, confer them /// Recalculate Pilot levels unlocked by the achievement if they arent already conferred, confer them /// </summary> /// <param name="dc"></param> /// <param name="taskID"></param> /// <param name="email"></param> private void ProcessTaskDependents(DBClassesDataContext dc, Guid taskID, string email) { // recalculate achievements for this pilot List <Guid> Achievements = RecalculateAchievements(dc, email); // save these achievements if (Achievements.Count > 0) { PilotAchievement.saveAchievements(dc, email, Achievements); } dc.SubmitChanges(); // Now calculate all rewards which are unlocked by this achievement List <Guid> Rewards = RecalculateRewards(dc, email, Achievements); if (Rewards.Count > 0) { PilotReward.saveRewards(dc, email, Rewards); } dc.SubmitChanges(); // Now calculate all rewards which are unlocked by this achievement List <Guid> Levels = RecalculateLevels(dc, email, Achievements); if (Rewards.Count > 0) { PilotClass.saveClasses(dc, email, Levels); } dc.SubmitChanges(); }
public int AddLogItem(DBClassesDataContext dbc, CompletionLog compLog) { // is there a record of this user performing this lesson ? bool bFound = false; foreach (LessonLogItem lli in mLog) { if (lli.StudentID == compLog.Student && lli.LessonID == compLog.LESSONID) { bFound = true; break; } } if (!bFound) { LessonLogItem log = new LessonLogItem(); log.DoneOn = compLog.DateCompleted; log.InstructorID = compLog.Instructor; log.InstructorName = AppUser.getUser(compLog.Instructor).GetFullName(); log.StudentID = compLog.Student; log.StudentName = AppUser.getUser(compLog.Student).GetFullName(); log.LessonID = compLog.LESSONID; log.LessonName = LESSON.GetLesson(dbc, compLog.LESSONID).Title; log.StageID = compLog.STAGEID; log.StageName = STAGE.GetStage(dbc, compLog.STAGEID).Name; // Update flight hours for this lesson for this student log.UpdateFlightHours(dbc); mLog.Add(log); } return(mLog.Count); }
protected void Page_Load(object sender, EventArgs e) { mUser = dashboard.getUserFromSessionOrCookie(Request, Session); if (mUser == null) { Response.Redirect("login.aspx"); Response.Close(); return; } String tail = Request.Params["tail"]; if (String.IsNullOrEmpty(tail) || !mUser.IsAdmin) { Response.Redirect("dashboard.aspx"); Response.Close(); return; } DBClassesDataContext dbc = new DBClassesDataContext(); Aircraft ship = (from u in dbc.Aircrafts where u.TailNumber == tail select u).SingleOrDefault(); if (ship != null) { dbc.Aircrafts.DeleteOnSubmit(ship); dbc.SubmitChanges(); } Response.Redirect("dashboard.aspx"); Response.Close(); return; }
protected void btnSave_Click(object sender, EventArgs e) { DBClassesDataContext dbc = new DBClassesDataContext(); if (NewType == null) { Aircraft ship = (from u in dbc.Aircrafts where u.TailNumber == mShip.TailNumber select u).SingleOrDefault(); mShip = ship; } else { dbc.Aircrafts.InsertOnSubmit(mShip); mShip.TailNumber = TailNum.Text; } mShip.Make = Make.Text; mShip.Model = Model.Text; mShip.Year = Year.Text; mShip.Status = ListStatus.SelectedIndex; dbc.SubmitChanges(); ExitPage(); }
public void ProcessRequest(HttpContext context) { string achievementid = context.Request.Form["achievementid"]; string achname = context.Request.Form["achievementname"]; string achdesc = context.Request.Form["achievementdescription"]; AchievementDefinition ach = new AchievementDefinition(); using (DBClassesDataContext dc = new DBClassesDataContext()) { try { if (String.IsNullOrEmpty(achievementid)) { dc.AchievementDefinitions.InsertOnSubmit(ach); ach.AchievementID = Guid.NewGuid(); } else { ach = (from u in dc.AchievementDefinitions where u.AchievementID == Guid.Parse(achievementid) select u).SingleOrDefault(); } ach.AchievementName = achname; ach.AchievementDesc = achdesc; dc.SubmitChanges(); } catch (Exception e) { } } }
private Dictionary <String, Object> GetPrereqsForReward(string rewardid) { Guid RewardGUID = Guid.Parse(rewardid); Dictionary <String, Object> finalList = new Dictionary <string, object>(); List <Object> finalAchList = new List <object>(); using (DBClassesDataContext dbc = new DBClassesDataContext()) { // load All achievements, then lookup each in achievementprereq to see if they are needed for achievement ID IEnumerable <AchievementDefinition> achs = (from u in dbc.AchievementDefinitions select u); foreach (AchievementDefinition ach in achs) { Dictionary <String, String> AchPre = new Dictionary <string, string>(); AchPre.Add("id", ach.AchievementID.ToString()); AchPre.Add("name", ach.AchievementName); IEnumerable <RewardPrereq> pre = (from u in dbc.RewardPrereqs where u.RequiredAchievement == ach.AchievementID && u.RewardID == RewardGUID select u); if (pre.Count <RewardPrereq>() == 0) { AchPre.Add("depends", "0"); } else { AchPre.Add("depends", "1"); } finalAchList.Add(AchPre); } finalList.Add("Achievements", finalAchList); } return(finalList); }
public void ProcessRequest(HttpContext context) { string pilotclassid = context.Request.Form["pilotclassid"]; string achname = context.Request.Form["pilotclassname"]; string logo = context.Request.Form["pilotlogo"]; string achdesc = context.Request.Form["pilotclassdescription"]; PilotClassDefinition ach = new PilotClassDefinition(); using (DBClassesDataContext dc = new DBClassesDataContext()) { try { if (String.IsNullOrEmpty(pilotclassid)) { dc.PilotClassDefinitions.InsertOnSubmit(ach); ach.PilotClassID = Guid.NewGuid(); } else { ach = (from u in dc.PilotClassDefinitions where u.PilotClassID == Guid.Parse(pilotclassid) select u).SingleOrDefault(); } ach.Logo = logo; ach.PilotClassName = achname; ach.PilotClassDescription = achdesc; dc.SubmitChanges(); } catch (Exception e) { } } }
public MainForm() { InitializeComponent(); dataContext = new DBClassesDataContext(); languageService = new LanguageService(dataContext); wordService = new WordService(dataContext); translationDBservice = new TranslationDBService(dataContext); applicationSettingsService = new ApplicationSettingsService(dataContext); titleToShortTitleMap = new Dictionary <String, String>(); selectLanguageComboBox.SelectedItem = "All"; //default insertLanguageComboBox.SelectedItem = "Polish"; //default isInternetAccess = checkInternetConnection(); if (isInternetAccess) { System.Environment.SetEnvironmentVariable("GOOGLE_APPLICATION_CREDENTIALS", "C:\\Programming\\IPNew\\IPV\\IP\\Inzenyria_programowania-ce5078cd8d32.json"); client = Google.Cloud.Translation.V2.TranslationClient.Create(); googleTranslate = new TranslationAPIService(client); foreach (Google.Cloud.Translation.V2.Language language in client.ListLanguages("en")) { if (languageService.checkIfLanguageExistsInDB(language.Name)) { insertLanguageComboBox.Items.Add(language.Name); titleToShortTitleMap.Add(language.Name, language.Code); } } } else { MessageBox.Show("Looks like you don't have internet connection, you can't add words, you can only exercise them."); } }
protected void Page_Load(object sender, EventArgs e) { mUser = dashboard.getUserFromSessionOrCookie(Request, Session); if (mUser == null) { Response.Redirect("login.aspx"); Response.Close(); return; } String uid = Request.Params["uid"]; if (String.IsNullOrEmpty(uid) || !mUser.IsAdmin) { Response.Redirect("dashboard.aspx"); Response.Close(); return; } DBClassesDataContext dbc = new DBClassesDataContext(); AppUser usr = (from u in dbc.AppUsers where u.UserEmail == uid select u).SingleOrDefault(); if (usr != null) { dbc.AppUsers.DeleteOnSubmit(usr); dbc.SubmitChanges(); } Response.Redirect("dashboard.aspx"); Response.Close(); return; }
protected String GetPilotClassForUser() { string pilotclass = "None"; using (DBClassesDataContext dbc = new DBClassesDataContext()) { IEnumerable <PilotClass> pcs = (from u in dbc.PilotClasses where u.PilotEmail == mUser.UserEmail select u); if (pcs != null && pcs.Count <PilotClass>() > 0) { pilotclass = ""; foreach (PilotClass pc in pcs) { PilotClassDefinition pcd = PilotClassDefinition.getPilotClassDefinition(pc.PilotClassID); if (pilotclass.Length > 0) { pilotclass += ", "; } pilotclass += pcd.PilotClassName; } } } return(pilotclass); }
internal static void delete(Guid achID) { using (DBClassesDataContext dbc = new DBClassesDataContext()) { // first remove any prereq involving this achievement IEnumerable <AchievementPrereq> achPrereqs = (from u in dbc.AchievementPrereqs where u.RequiredAchievementID == achID select u); dbc.AchievementPrereqs.DeleteAllOnSubmit(achPrereqs); // first remove any prereq involving this achievement IEnumerable <RewardPrereq> rewPrereqs = (from u in dbc.RewardPrereqs where u.RequiredAchievement == achID select u); dbc.RewardPrereqs.DeleteAllOnSubmit(rewPrereqs); // first remove any prereq involving this achievement IEnumerable <PilotClassPrereq> pcPrereqs = (from u in dbc.PilotClassPrereqs where u.AchievementID == achID select u); dbc.PilotClassPrereqs.DeleteAllOnSubmit(pcPrereqs); AchievementDefinition ach = (from u in dbc.AchievementDefinitions where u.AchievementID == achID select u).SingleOrDefault(); if (ach != null) { dbc.AchievementDefinitions.DeleteOnSubmit(ach); dbc.SubmitChanges(); } } }
internal static AppUser getUser(DBClassesDataContext dbc, string uid) { AppUser usr = (from u in dbc.AppUsers where u.UserEmail == uid select u).SingleOrDefault(); return(usr); }
internal static int GetTotalShips() { DBClassesDataContext dbc = new DBClassesDataContext(); int nAc = (from u in dbc.Aircrafts select u).Count(); return(nAc); }
public static STAGE GetStage(DBClassesDataContext dbc, int sid) { STAGE li = (from l in dbc.STAGEs where l.STAGEID == sid select l).SingleOrDefault(); return(li); }
public static LESSON GetLesson(DBClassesDataContext dbc, int lid) { LESSON li = (from l in dbc.LESSONs where l.LESSONID == lid select l).SingleOrDefault(); return(li); }
public static IEnumerable <PilotClassDefinition> getAll() { DBClassesDataContext dbc = new DBClassesDataContext(); IEnumerable <PilotClassDefinition> ach = (from u in dbc.PilotClassDefinitions select u); return(ach.ToList()); }
internal static IEnumerable <LessonTimeLog> LoadStudentLog(DBClassesDataContext dbc, string optionalStudent) { IEnumerable <LessonTimeLog> log = (from u in dbc.LessonTimeLogs where (u.Student == optionalStudent) select u); return(log); }
internal static IEnumerable <Aircraft> GetAll() { DBClassesDataContext dbc = new DBClassesDataContext(); IEnumerable <Aircraft> usrs = (from u in dbc.Aircrafts select u); return(usrs); }
// if the user exists and is valid, return the user, else return null internal static Aircraft getAircraft(string tail) { DBClassesDataContext dbc = new DBClassesDataContext(); Aircraft ac = (from u in dbc.Aircrafts where u.TailNumber == tail select u).SingleOrDefault(); return(ac); }
public bool IsStarted = false; // unstarted by default // if the user exists and is valid, return the user, else return null internal static FAACert getCert(string cert) { DBClassesDataContext dbc = new DBClassesDataContext(); FAACert ac = (from u in dbc.FAACerts where u.CertificationID == cert select u).SingleOrDefault(); return(ac); }
private Dictionary <String, Object> GetPrereqsForAchievement(string achievementID) { Guid achievementGUID = Guid.Parse(achievementID); Dictionary <String, Object> finalList = new Dictionary <string, object>(); List <Object> finalAchList = new List <object>(); List <Object> finalTaskList = new List <object>(); using (DBClassesDataContext dbc = new DBClassesDataContext()) { // load All achievements, then lookup each in achievementprereq to see if they are needed for achievement ID IEnumerable <AchievementDefinition> achs = (from u in dbc.AchievementDefinitions select u); foreach (AchievementDefinition ach in achs) { Dictionary <String, String> AchPre = new Dictionary <string, string>(); AchPre.Add("id", ach.AchievementID.ToString()); AchPre.Add("name", ach.AchievementName); IEnumerable <AchievementPrereq> pre = (from u in dbc.AchievementPrereqs where u.RequiredAchievementID == ach.AchievementID && u.AchievementID == achievementGUID select u); if (pre.Count <AchievementPrereq>() == 0) { AchPre.Add("depends", "0"); } else { AchPre.Add("depends", "1"); } finalAchList.Add(AchPre); } finalList.Add("Achievements", finalAchList); // load All tasks, then lookup each in achievementprereq to see if they are needed for achievement ID IEnumerable <TaskDefinition> tasks = (from u in dbc.TaskDefinitions select u); foreach (TaskDefinition tsk in tasks) { Dictionary <String, String> TaskPre = new Dictionary <string, string>(); TaskPre.Add("taskid", tsk.TaskID.ToString()); TaskPre.Add("taskname", tsk.TaskName); IEnumerable <AchievementPrereq> pre = (from u in dbc.AchievementPrereqs where u.TaskID == tsk.TaskID && u.AchievementID == achievementGUID select u); if (pre.Count <AchievementPrereq>() == 0) { TaskPre.Add("depends", "0"); } else { TaskPre.Add("depends", "1"); } finalTaskList.Add(TaskPre); } } finalList.Add("Tasks", finalTaskList); return(finalList); }
// if the user exists and is valid, return the user, else return null public static IEnumerable <Guid> getAchievementsForPrereqAchievement(Guid achid) { DBClassesDataContext dbc = new DBClassesDataContext(); IEnumerable <Guid> ach = (from u in dbc.AchievementPrereqs where u.RequiredAchievementID == achid select u.AchievementID); return(ach); }
// if the user exists and is valid, return the user, else return null public static IEnumerable <Guid> getAchievementsForPrereqTask(Guid taskid) { DBClassesDataContext dbc = new DBClassesDataContext(); IEnumerable <Guid> ach = (from u in dbc.AchievementPrereqs where u.TaskID == taskid select u.AchievementID); return(ach); }
// if the user exists and is valid, return the user, else return null internal static AchievementDefinition getAchievementDefinition(Guid defid) { DBClassesDataContext dbc = new DBClassesDataContext(); AchievementDefinition ach = (from u in dbc.AchievementDefinitions where u.AchievementID == defid select u).SingleOrDefault(); return(ach); }
// if the user exists and is valid, return the user, else return null internal static RewardDefinition getRewardDefinition(Guid defid) { DBClassesDataContext dbc = new DBClassesDataContext(); RewardDefinition ach = (from u in dbc.RewardDefinitions where u.RewardID == defid select u).SingleOrDefault(); return(ach); }
internal static int GetTotalInstructors() { DBClassesDataContext dbc = new DBClassesDataContext(); int nUsers = (from u in dbc.AppUsers where u.IsInstructor == true select u).Count(); return(nUsers); }
internal static IEnumerable <AppUser> GetStudents() { DBClassesDataContext dbc = new DBClassesDataContext(); IEnumerable <AppUser> usrs = (from u in dbc.AppUsers where u.IsStudent == true select u); return(usrs.ToList()); }
public static IEnumerable <TaskDefinition> getAllTaskDefinitions() { using (DBClassesDataContext dbc = new DBClassesDataContext()) { IEnumerable <TaskDefinition> tasks = (from u in dbc.TaskDefinitions select u); return(tasks.ToList()); } }
// if the user exists and is valid, return the user, else return null public static List <Guid> getVerifiedTasksIDsForPilot(String pilotid) { using (DBClassesDataContext dbc = new DBClassesDataContext()) { IEnumerable <Guid> tsks = (from u in dbc.PilotTasks where u.PilotEmail == pilotid && u.IsVerified == true select u.TaskID); return(tsks.ToList()); } }