public void MemberSelect(int memberID, int projectID) { SeniorProject db = new SeniorProject(); var select = from o in db.Member where o.ID == memberID && o.ProjectID == projectID select o; }
public ActionResult SaveReportData(int?id) { // SeniorProject seniorProject = db.SeniorProject.OrderByDescending(o => o.SPtId).FirstOrDefault(); SeniorProject seniorProject = new SeniorProject(); seniorProject = db.SeniorProjects.Find(id); if (seniorProject == null) { return(HttpNotFound()); } ProjectVM project = new ProjectVM(); project = GetStuFromPDF(seniorProject.SPtId); project.SPName = seniorProject.SPName; project.SPtId = seniorProject.SPtId; /*List<Student> students = new List<Student>(); * students=obj.StudentsAndID; * /* Supervisors sup = new Supervisors(); * sup=obj.Sup; * seniorProject.SPAbstract = obj.Project.SPAbstract; * var TwoModel = new ProjectAndStudentModels { project = seniorProject, StudentsAndID = students, supervisors = sup }; */ return(View(project)); }
public ActionResult Project(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } SeniorProject seniorProject = db.SeniorProjects.Find(id); if (seniorProject == null) { return(HttpNotFound()); } SeniorProject s = new SeniorProject() { SPVideos = seniorProject.SPVideos, SPName = seniorProject.SPName, SPAbstract = seniorProject.SPAbstract, progLang = seniorProject.progLang, User = seniorProject.User, Users = (from ss in db.Users where ss.projectGroup == id select ss).ToList(), // To select group members in the project }; return(View(s)); }
public ActionResult updateSupervisor(ProjectVM model) { try { SeniorProject project = db.SeniorProjects.Find(model.SPtId); project.supervisorUserId = model.supervisor.userId; User sup = db.Users.Find(model.userId); if (sup == null) { sup = new User(); sup.userId = model.supervisor.userId; sup.userId = model.supervisor.userName; sup.userRole = model.supervisor.userRole = 2; using (Entities entity = new Entities()) { entity.Users.Add(sup); entity.SaveChanges(); } } db.Entry(project).State = EntityState.Modified; db.SaveChanges(); return(new JsonResult { Data = "Supervisor updated successfully" }); } catch (Exception ex) { return(new JsonResult { Data = "an error occurred" }); } }
public void ContractSelect(int inputID) { SeniorProject db = new SeniorProject(); var select = from o in db.Contract where o.ID == inputID select o; }
private void ProjectEdit(int SPtId, string SPName, string SPVideos, string SPAbstract, string SPGrade, string PL, string Section, short?year, HttpPostedFileBase file) { SeniorProject project = db.SeniorProjects.Find(SPtId); project.SPtId = SPtId; project.SPName = SPName; project.SPAbstract = SPAbstract; project.SPVideos = SPVideos; project.SPGrade = SPGrade; project.progLang = PL; project.Section = Section; project.Year = year; if (file != null && file.ContentLength > 0) { DateTime now = DateTime.Now; if (Path.GetExtension(file.FileName).ToUpper() == ".PDF") { // Get file data byte[] data = new byte[] { }; using (var binaryReader = new BinaryReader(file.InputStream)) { data = binaryReader.ReadBytes(file.ContentLength); } project.SPReport = data; } } db.Entry(project).State = EntityState.Modified; db.SaveChanges(); }
public ActionResult DeleteConfirmed(int id) { SeniorProject seniorProject = db.SeniorProjects.Find(id); db.SeniorProjects.Remove(seniorProject); db.SaveChanges(); return(RedirectToAction("Projects", "SeniorProjectt")); }
public ActionResult InsertProject(ProjectValidation model) { SeniorProject Project = db.SeniorProjects.OrderByDescending(o => o.SPtId).FirstOrDefault(); ProjectEdit(Project.SPtId, model.Section, (Int16)model.Year); int year = model.Year.Value; return(RedirectToAction("SaveReportData", new { id = Project.SPtId })); }
public void ProjectEdit(int SPtId, string sec, short year) { SeniorProject project = db.SeniorProjects.Find(SPtId); project.SPtId = SPtId; project.Section = sec; project.Year = year; db.Entry(project).State = EntityState.Modified; db.SaveChanges(); }
/***********************************************************************************************************************************************/ public void ProjectEdit(int SPtId, string SPName, string link, string SPAbstract, string grade, string PL) { SeniorProject project = db.SeniorProjects.Find(SPtId); project.SPtId = SPtId; project.SPName = SPName; project.SPAbstract = SPAbstract; project.SPVideos = link; project.SPGrade = grade; project.progLang = PL; db.Entry(project).State = EntityState.Modified; db.SaveChanges(); }
// GET: SeniorProjects/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } SeniorProject seniorProject = db.SeniorProjects.Find(id); if (seniorProject == null) { return(HttpNotFound()); } return(View(seniorProject)); }
public void Connect(string hostname, int port, string root, string password, string database) { //using (var context = new SeniorProject()) { // var res = from u in context.User // } string conn = "Server=" + hostname + ";user="******";database=" + database + ";port=" + port + ";password="******"Connected..."); } catch (Exception ex) { Console.WriteLine(ex); } }
private void CreateDatabaseInstance() { DatabaseInstance = new SeniorProject(); }
public ActionResult AddSupervisortoProject(ProjectVM model) { // assigen supervisor id to project if (model.supervisor.userId != null) { //first check if this supervisor exists in the db or not // Supervisor supervisor = db.Supervisors.Find(model.supervisorId); User supervisor = db.Users.Find(model.supervisor.userId); if (supervisor == null) { //supervisor = new Supervisor(); supervisor = new User(); supervisor.userId = model.userId; supervisor.userName = model.userName; supervisor.userRole = 2; using (Entities entity = new Entities()) { entity.Users.Add(supervisor); entity.SaveChanges(); } } SeniorProject project = db.SeniorProjects.Find(model.SPtId); project.supervisorUserId = model.supervisor.userId; db.Entry(project).State = EntityState.Modified; db.SaveChanges(); //List of aoi of this project List <int> areaId = new List <int>(); areaId = (from FC in db.ProjectsAOIs where FC.SPtId == model.SPtId select FC.AOIId).ToList(); //List of aoi of this supervisor List <int> SupareaId = new List <int>(); SupareaId = (from FC in db.SupAOIs where FC.supervisorUserId == model.supervisor.userId select FC.AOIId).ToList(); //to find aoi for this project but not assigened to this supervisor IEnumerable <int> AOIDifference; AOIDifference = areaId.Except(SupareaId); // assigen area of interest to this supervisor foreach (var item in AOIDifference) { SupAOI saoi = new SupAOI(); saoi.AOIId = item; saoi.supervisorUserId = model.supervisor.userId; using (Entities entity = new Entities()) { entity.SupAOIs.Add(saoi); entity.SaveChanges(); } } /*return new JsonResult * { * Data = "Saved successfully" * };*/ } return(new JsonResult { Data = "Saved successfully" }); }
public ActionResult ReportUpload(HttpPostedFileBase file) { int projectID = 0; try { if (file != null && file.ContentLength > 0) { var contentLength = file.ContentLength; var contentType = file.ContentType; DateTime now = DateTime.Now; ViewBag.PTitlE = Path.GetFileNameWithoutExtension(file.FileName); string extenstion = ""; if (Path.GetExtension(file.FileName).ToUpper() == ".PDF") { // Get file data byte[] data = new byte[] { }; using (var binaryReader = new BinaryReader(file.InputStream)) { data = binaryReader.ReadBytes(file.ContentLength); } var SeniorProject = new SeniorProject() { // SPName = report.FileName, SPName = Path.GetFileNameWithoutExtension(file.FileName), SPReport = data, /// supervisorId = "10", }; using (Entities entity = new Entities()) { entity.SeniorProjects.Add(SeniorProject); entity.SaveChanges(); } projectID = SeniorProject.SPtId; return(new JsonResult { Data = "file uploaded successfully" }); } else { extenstion = (Path.GetExtension(file.FileName) + "not allowed only .pdf files"); return(new JsonResult { Data = extenstion }); } } } catch (Exception ex) { return(new JsonResult { Data = "an error occuerd" }); } return(new JsonResult { Data = "file is empety" }); } // }
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@End SaveReport View functions@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@// /************Edit students update page************/ public ActionResult Edit(int?id) { try { SeniorProject senproject = db.SeniorProjects.Find(id); ProjectVM projectvm = new ProjectVM(); projectvm.Year = senproject.Year; projectvm.SPName = senproject.SPName; projectvm.SPtId = senproject.SPtId; projectvm.SPVideos = senproject.SPVideos; projectvm.SPAbstract = senproject.SPAbstract; projectvm.SPGrade = senproject.SPGrade; projectvm.Section = senproject.Section; projectvm.Year = senproject.Year; projectvm.PLList = new List <string>(); if (senproject.progLang != null) { List <string> progLang = senproject.progLang.Split(',').ToList(); projectvm.PLList = progLang; } List <string> AOI = new List <string>(); AOI = (from FC in db.ProjectsAOIs where FC.SPtId == id select FC.AreaOFInterest.AOIName).ToList(); projectvm.AOIList = new List <string>(); projectvm.AOIList = AOI; List <string> Awards = new List <string>(); Awards = (from FC in db.ProjectAwards where FC.ProjectId == id select FC.Award.awardName).ToList(); projectvm.AwardsList = new List <string>(); projectvm.AwardsList = Awards; ///////////////////////// if (senproject.supervisorUserId != null) { //projectvm.supervisor.userId = senproject.supervisorUserId; //User supervisor = db.Users.Find(projectvm.supervisor.userId); //projectvm.supervisor.userName = supervisor.userName; projectvm.userId = senproject.supervisorUserId; projectvm.userName = senproject.User.userName; } else { //projectvm.supervisor.userId = ""; //projectvm.supervisor.userName = ""; projectvm.userId = ""; projectvm.userName = ""; } //////////////////////// List <User> stu = (from FC in db.Users where FC.projectGroup == id select FC).ToList(); projectvm.Users = new List <User>(); if (stu != null) { projectvm.Users = stu; } return(View(projectvm)); } catch (Exception ex) { return(RedirectToAction("ErrorMessage", new { msg = "an error occurred" + ex.Message })); } }
public void ContractDelete(int inputID) { SeniorProject db = new SeniorProject(); var delete = db.Contract.Single(contract => contract.ID == inputID) db.Contract.RemoveContractRow(); }
public DBConnected() { DBInstance = DatabaseConnector.databaseConnectorSingleton.GetDatabaseInstance(); }