public StudentModel SearchStudent(int idStudent) { appStudent = new StudentApplication(); try { StudentModel obj = new StudentModel(); foreach (DataRow linha in appStudent.QuerieStudent(idStudent).Rows) { obj.idStudent = Convert.ToInt32(linha["idStudent"]); obj.nameStudent = Convert.ToString(linha["nameStudent"]); obj.registrationNumber = Convert.ToString(linha["registrationNumber"]); obj.birthDate = Convert.ToDateTime(linha["birthDate"]); if (!linha["nameClassroom"].ToString().Equals("")) { obj.nameClassroomModel = Convert.ToString(linha["nameClassroom"]); } else { obj.nameClassroomModel = "---"; } } return(obj); } catch (Exception) { throw; } }
public async Task <IActionResult> Create([Bind("OpportunityId,ExpectedGraduation,DegreePlan,GPA,Availability,PersonalStatement,IsLookingForPosition")] StudentApplication studentApplication) { var user = await _userManager.GetUserAsync(this.User); var oldApplication = await _context.StudentApplications .Include(e => e.Student) .Include(e => e.Opportunity) .Where(e => e.Student.StudentId == user.Id && e.Opportunity.OpportunityId == studentApplication.OpportunityId) .FirstOrDefaultAsync(); if (oldApplication != null) { return(BadRequest("Cannot create application to oportunity you have already applied to")); } var student = await GetStudentAsync(user); studentApplication.Student = student; studentApplication.UId = user.UId; studentApplication.TimeModified = DateTime.UtcNow; if (ModelState.IsValid) { _context.Add(studentApplication); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(studentApplication)); }
public List <StudentModel> ListStudent(int idLoginAccess) { appStudent = new StudentApplication(); List <StudentModel> listStudent = new List <StudentModel>(); try { foreach (DataRow linha in appStudent.QuerieAllStudent(idLoginAccess).Rows) { StudentModel obj = new StudentModel(); obj.idStudent = Convert.ToInt32(linha["idStudent"]); obj.nameStudent = Convert.ToString(linha["nameStudent"]); obj.registrationNumber = Convert.ToString(linha["registrationNumber"]); obj.birthDate = Convert.ToDateTime(linha["birthDate"]); if (!linha["nameClassroom"].ToString().Equals("")) { obj.nameClassroomModel = Convert.ToString(linha["nameClassroom"]); } else { obj.nameClassroomModel = "---"; } listStudent.Add(obj); } return(listStudent); } catch (Exception) { throw; } }
public ActionResult DeleteConfirmed(int id) { StudentApplication studentApplication = db.StudentApplications.Find(id); db.StudentApplications.Remove(studentApplication); db.SaveChanges(); return(RedirectToAction("Index")); }
public async Task <ActionResult> DeleteConfirmed(int id) { StudentApplication studentApplication = await db.StudentApplication.FindAsync(id); db.StudentApplication.Remove(studentApplication); await db.SaveChangesAsync(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "Id,FirstName,LastName,Email,HighSchool,EstGradDate,WindowsLaptop,CSAComplete,Accomplishments,PresentAllClassDates,MissedClassDates,PresentAllSeasonDates,MissedSeasonDates")] StudentApplication studentApplication) { if (ModelState.IsValid) { service.Edit(studentApplication); return(RedirectToAction("Index")); } return(View(studentApplication)); }
public ActionResult Edit([Bind(Include = "Id,timestamp,name,email,currentSchool,eligible,age,phoneNumber,graduationDate")] StudentApplication studentApplication) { if (ModelState.IsValid) { db.Entry(studentApplication).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(studentApplication)); }
public async Task <IActionResult> Edit(int id, [Bind("OpportunityId,ExpectedGraduation,DegreePlan,GPA,Availability,PersonalStatement,IsLookingForPosition")] StudentApplication studentApplication) { var user = await _userManager.GetUserAsync(this.User); var student = await _context.Students.FindAsync(user.Id); var application = await _context.StudentApplications .Include(o => o.Student) .FirstOrDefaultAsync(m => m.Student.StudentId == user.Id); studentApplication.Student = student; studentApplication.StudentApplicationId = application.StudentApplicationId; if (id != studentApplication.StudentApplicationId) { return(NotFound()); } if (studentApplication.Student.StudentId != user.Id) { return(BadRequest(new { message = "You do not have permission to edit this application" })); } ModelState.Remove("StudentId"); ModelState.Remove("StudentApplicationId"); if (ModelState.IsValid) { try { application.ExpectedGraduation = studentApplication.ExpectedGraduation; application.DegreePlan = studentApplication.DegreePlan; application.GPA = studentApplication.GPA; application.UId = studentApplication.UId; application.Availability = studentApplication.Availability; application.PersonalStatement = studentApplication.PersonalStatement; application.IsLookingForPosition = studentApplication.IsLookingForPosition; _context.Update(application); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!StudentApplicationExists(studentApplication.StudentApplicationId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(studentApplication)); }
public ActionResult Create([Bind(Include = "Id,timestamp,name,email,currentSchool,eligible,age,phoneNumber,graduationDate")] StudentApplication studentApplication) { if (ModelState.IsValid) { studentApplication.timestamp = DateTime.Now; db.StudentApplications.Add(studentApplication); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(studentApplication)); }
public async Task <ActionResult> Edit([Bind(Include = "StudentApplicationId,ApplicationStatusId,StudentName,ProgramId")] StudentApplication studentApplication) { if (ModelState.IsValid) { db.Entry(studentApplication).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index")); } ViewBag.ApplicationStatusId = new SelectList(db.ApplicationStatus, "ApplicationStatusId", "StatusName", studentApplication.ApplicationStatusId); ViewBag.ProgramId = new SelectList(db.Program, "ProgramId", "Name", studentApplication.ProgramId); return(View(studentApplication)); }
// GET: StudentApplications/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } StudentApplication studentApplication = db.StudentApplications.Find(id); if (studentApplication == null) { return(HttpNotFound()); } return(View(studentApplication)); }
public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } StudentApplication studentApplication = service.GetStudentApplicationById((int)id); if (studentApplication == null) { return(HttpNotFound()); } return(View(studentApplication)); }
// GET: StudentApplications/Details/5 public async Task <ActionResult> Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } StudentApplication studentApplication = await db.StudentApplication.FindAsync(id); if (studentApplication == null) { return(HttpNotFound()); } return(View(studentApplication)); }
// GET: StudentApplications/Edit/5 public async Task <ActionResult> Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } StudentApplication studentApplication = await db.StudentApplication.FindAsync(id); if (studentApplication == null) { return(HttpNotFound()); } ViewBag.ApplicationStatusId = new SelectList(db.ApplicationStatus, "ApplicationStatusId", "StatusName", studentApplication.ApplicationStatusId); ViewBag.ProgramId = new SelectList(db.Program, "ProgramId", "Name", studentApplication.ProgramId); return(View(studentApplication)); }
private StaffInboxItemVM MapApplicationToInboxItemVM(StudentApplication application) { return(new StaffInboxItemVM { StudentApplicationId = application.StudentApplicationId, StudentName = application.StudentName, StudentNumber = application.StudentNumber, LastUpdatedAt = application.LastUpdatedAt, ExchangeUniversityName = application.ExchangeUniversityName, ExchangeUniversityHref = application.ExchangeUniversityHref, StudentApplicationStatus = new SelectOption <StudentApplicationStatus>( application.Status, application.Status.ToString(), false ) }); }
public bool SignUp(StudentApplication studentApplication) { if (studentApplication != null) { if (!securityProvider.IsNidOrBirthRegNoExisi(studentApplication.NidOrBirtgRegNo)) { if (!securityProvider.IsUserNameExisis(studentApplication.UserName)) { if (!securityProvider.IsEmailExist(studentApplication.EmailAddress)) { studentApplication.AccountId = CreateGuid(); db.StudentApplications.Add(studentApplication); db.SaveChanges(); return(true); } } } } return(false); }
protected void SubmitApplicationBtn_Click(object sender, EventArgs e) { if (SQLDataAccess.IsUsernameAvailable(inputUsername.Value, "student")) { HideErrorMsg(); //validate input first string salt = PasswordManager.GenerateSalt(); StudentApplication application = new StudentApplication { Status = "Pending", FirstName = inputFirstName.Value, LastName = inputLastName.Value, CreateDate = DateTime.Now, UpdateDate = DateTime.Now, Username = inputUsername.Value, HashedPassword = PasswordManager.HashPassword(inputPassword.Value, salt), PasswordSalt = salt, Email = inputEmail.Value, PhoneNumber = inputPhoneNumber.Value, Address1 = inputAddress.Value, Address2 = inputAddress2.Value, City = inputCity.Value, State = inputState.Value, ZipCode = inputZip.Value, ApplicantType = "student" }; if (SQLDataAccess.SaveApplication(application)) { ApplicationPanel.Visible = false; SuccessMsg.Visible = true; } } else { ShowErrorMsg("That username already exists"); } }
public void Add(StudentApplication toAdd) { repo.Add(toAdd); }
public void Delete(StudentApplication toDelete) { db.StudentApplications.Remove(toDelete); db.SaveChanges(); }
public void Edit(StudentApplication toEdit) { db.Entry(toEdit).State = EntityState.Modified; db.SaveChanges(); }
public void Add(StudentApplication toAdd) { db.StudentApplications.Add(toAdd); db.SaveChanges(); }
private void btnSubmitApplication_Click(object sender, EventArgs e) { StudentApplication app = new StudentApplication(); // check personal Information if (txtName.Text.Equals("") || txtFatherName.Text.Equals("") || txtEmail.Text.Equals("") || txtPhoneNumber.Text.Equals("") || txtIDCard.Equals("")) { MessageBox.Show("Personal information Incomplete"); return; } try { MailAddress email = new MailAddress(txtEmail.Text); } catch { MessageBox.Show("Email Address is not valid"); } // add Personal Information app.student_name = txtName.Text; app.std_father_name = txtFatherName.Text; app.std_email = txtEmail.Text; app.std_phone_number = txtPhoneNumber.Text; app.std_id_card = txtIDCard.Text; // check Educational Information if (numMatricMarks.Value.Equals(0) || numMatricMarks.Value.Equals(0) || numEcatMarks.Value.Equals(0)) { MessageBox.Show("Incomplete Educational Details"); return; } // add educational details app.Matric_got_marks = Convert.ToInt32(numMatricMarks.Value); app.FSC_got_marks = Convert.ToInt32(numFSCMarks.Value); app.ECAT_got_marks = Convert.ToInt32(numEcatMarks.Value); app.GAT_got_marks = Convert.ToInt32(numGatMarks.Value); app.aggregate = calculateAggrigate(app.FSC_got_marks, app.ECAT_got_marks); app.app_ref_number = APPLICATION.applications.Count + 1; // check Preference List if (prefs.Count == 3) { // Add Preference List app.preferences = prefs; } else { MessageBox.Show("You Must Add 3 Preferences"); return; } // Application Ready.. Now Add into Database if (APPLICATION.AddStudentApplication(app)) { MessageBox.Show("Application Submitted Successfully"); // new Binding Source to display in Applications Data Grid BindingSource bs = new BindingSource(); bs.DataSource = APPLICATION.applications; dataGridApplications.DataSource = bs; // function call to print the receipt for the Student // // clear the Filled Text Boxes txtName.Text = ""; txtFatherName.Text = ""; txtIDCard.Text = ""; txtPhoneNumber.Text = ""; txtEmail.Text = ""; numMatricMarks.Value = 0; numFSCMarks.Value = 0; numEcatMarks.Value = 0; numGatMarks.Value = 0; dataGridPreferences.DataSource = null; prefs = null; personalInfoPanel.BringToFront(); panelApplications.Visible = false; } }
private static StudentApplication MapApplicationFormToApplication(ExchangeDbContext db, ApplicationFormVM form, bool asStaff) { var now = DateTime.UtcNow; Func <String, UWAUnitLevel?> parseUnitLevel = (label) => { object level; if (Enum.TryParse(typeof(UWAUnitLevel), label, true, out level)) { return((UWAUnitLevel?)level); } return((UWAUnitLevel?)null); }; var newApplication = new StudentApplication { SubmittedAt = now, LastUpdatedAt = now, StudentName = form.StudentDetailsForm.Name, StudentNumber = form.StudentDetailsForm.Email, Major1st = form.StudentDetailsForm.Major, Major2nd = form.StudentDetailsForm.Major2nd, StudentOffice = form.StudentDetailsForm.StudentOffice?.Value, ExchangeUniversityCountry = form.ExchangeUniversityForm.UniversityCountry, ExchangeUniversityName = form.ExchangeUniversityForm.UniversityName, ExchangeUniversityHref = form.ExchangeUniversityForm.UniversityHomepage, UnitSets = form.UnitSetForms.Select(f => new UnitSet { ExchangeUniversityCountry = form.ExchangeUniversityForm.UniversityCountry, ExchangeUniversityName = form.ExchangeUniversityForm.UniversityName, ExchangeUniversityHref = form.ExchangeUniversityForm.UniversityHomepage, IsEquivalent = asStaff ? f.StaffApprovalForm.IsEquivalent.Value : (bool?)null, IsContextuallyApproved = asStaff ? f.StaffApprovalForm.IsContextuallyApproved.Value : (bool?)null, EquivalentUWAUnitLevel = asStaff ? parseUnitLevel(f.StaffApprovalForm.EquivalentUnitLevel.Label) : (UWAUnitLevel?)null, ExchangeUnits = f.ExchangeUnitForms.Select(u => new ExchangeUnit { Code = u.UnitCode, Title = u.UnitName, Href = u.UnitHref }).ToList(), UWAUnits = f.UWAUnitForms?.Select(u => new UWAUnit { Code = u.UnitCode, Title = u.UnitName, Href = u.UnitHref }).ToList() ?? new List <UWAUnit>(), Comments = f.StaffApprovalForm.Comments }).ToList(), }; /* Calculate the status of the application */ newApplication.Status = MapUnitSetsToStatus(newApplication.UnitSets); /* Preserve when the student submitted the application */ if (asStaff && form.ApplicationId.HasValue) { var oldApplication = db.StudentApplications.FirstOrDefault(a => a.StudentApplicationId == form.ApplicationId); if (oldApplication != null) { newApplication.SubmittedAt = oldApplication.SubmittedAt; } } return(newApplication); }
public string ImportStudent(StudentModel studentModel, HttpFileCollectionBase files) { try { List <Student> list = new List <Student>(); string msgReturn = ""; if (files != null) { // Tratamento de arquivo, verifica se tem documento e converte para ArrayBytes string[] fieldNames = files.AllKeys; for (int i = 0; i < fieldNames.Length; ++i) { HttpPostedFileBase file = files[i]; string field = fieldNames[i]; if (!file.FileName.Equals("")) { string fileName = files[i].FileName; //O caminho para o arquivo no computador empresa Stream stream = files[i].InputStream; //Os dados reais do arquivo //Converte o arquivo que está num formato stream para byte[] byte[] bytes = new byte[stream.Length]; stream.Read(bytes, 0, bytes.Length); ExcelPackage.LicenseContext = LicenseContext.NonCommercial; //gen the byte array into the memorystream using (MemoryStream ms = new MemoryStream(bytes)) using (ExcelPackage package = new ExcelPackage(ms)) { //get the first sheet from the excel file ExcelWorksheet sheet = package.Workbook.Worksheets[0]; int column = 0; int row = 0; Student student = new Student(); foreach (var item in sheet.Cells) { if (column == 3) { row++; if (row > 1) { list.Add(student); } student = new Student(); column = 0; } column++; if (row >= 1) { if (column == 1) { student.registrationNumber = Convert.ToString(item.Value); } else if (column == 2) { student.nameStudent = Convert.ToString(item.Value); } else if (column == 3) { student.birthDate = Convert.ToDateTime(item.Value); } } } } } } } if (list.Count > 0) { appStudent = new StudentApplication(); msgReturn = appStudent.InsertListStudent(list, studentModel.idLoginAccess); } else { msgReturn = Message.ErrorSpreadsheetStudent; } return(msgReturn); } catch (Exception) { throw; } }
public void Edit(StudentApplication toEdit) { repo.Edit(toEdit); }
public void Delete(StudentApplication toDelete) { repo.Delete(toDelete); }
public int Update(StudentApplication studentApplication) { context.StudentApplication.AddOrUpdate(studentApplication); return(context.SaveChanges()); }