// the name of the entity's template being edited is passed in so that the code knows which // data to pull from the database public IActionResult EditAppTempEntity(string eName) { var entity = new entityInfo(); entity.entityName = eName; var disabledFields = new List <string>(); var enabledFields = new List <string>(); using (var context = new Models.ApplicationDbContext()) { // get any disabled fields disabledFields = (from temp in context.ApplicationTemplate where temp.Entity == entity.entityName && temp.Deleted == true select temp.ProperName).ToList(); // get all enabled fields enabledFields = (from temp in context.ApplicationTemplate where temp.Entity == entity.entityName select temp.ProperName).ToList(); } // entity being changed as well as a list of enabled and disabled fields // are returned to the view ViewBag.entity = entity.entityName; ViewBag.enabledFields = enabledFields; ViewBag.disabledFields = disabledFields; return(View()); }
/*Displays current application template fields onto web page */ public IActionResult Application(string eName) { var entity = new entityInfo(); entity.entityName = eName; //returns all entries in the application template table //and data filled out by student to date using (var context = new Interactive_Internship_Application.Models.ApplicationDbContext()) { var getSingleFieldName = from app in _dataContext.ApplicationTemplate where app.Deleted == false select app; var studentValues = from data in _dataContext.ApplicationTemplate where data.Entity == "Student" where data.FieldName.Contains("sig") || data.FieldName.Contains("date") where data.FieldDescription.Contains("guidelines") || data.FieldDescription.Contains("intern_sig2") select data; var filledOutGood = new Dictionary <int, string>(); //if previously saved application, grab data that was saved if (eName != "createNew") { //get current user's email and ID for class var studentEmail = (from student in context.StudentInformation where student.Email == User.Identity.Name.ToString() select student.Email).FirstOrDefault(); //get all application IDs for student var currStudentRecordId = (from stuAppNum in context.StudentAppNum where stuAppNum.StudentEmail == studentEmail select stuAppNum.Id).ToList(); //get applicationID for particular class int correctID = 0; foreach (var currID in currStudentRecordId) { var classNameCurr = (from appData in context.ApplicationData join appTemp in context.ApplicationTemplate on appData.DataKeyId equals appTemp.Id where appData.RecordId == currID where appTemp.FieldName == "class_enrolled" select appData.Value).First().ToString(); if (classNameCurr == eName) { correctID = currID; } } //get applicationData for particular class's application var filledOut = from appData in context.ApplicationData where appData.RecordId == correctID select appData; filledOutGood = filledOut.ToDictionary(what => what.DataKeyId, who => who.Value); ViewBag.appID = correctID; } ViewBag.className = eName; ViewBag.fieldNames = getSingleFieldName; ViewBag.studentValues = studentValues; return(View(filledOutGood)); } }