public ActionResult Create(ApplicantVm avm, HttpPostedFileBase File) { if (ModelState.IsValid) { if (File != null && File.ContentLength != 0) { applicant applicant = new applicant() { lastname = avm.lastname, name = avm.name, password = avm.password, picture = File.FileName, username = avm.username, age = avm.age, country = avm.country.ToString() }; HttpClient client = new HttpClient(); client.BaseAddress = new Uri("http://localhost:18080"); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); client.PostAsJsonAsync <applicant>("/l4c_map-v2-web/rest/inscription", applicant).ContinueWith((postTask) => postTask.Result.EnsureSuccessStatusCode()); if (File.ContentLength > 0) { var path = Path.Combine(Server.MapPath("~/images/"), File.FileName); File.SaveAs(path); } return(RedirectToAction("Login", "User")); } } return(View(avm)); }
public ActionResult Accept(ApplicantVm avm) { applicant applicant = new applicant() { id = avm.id, applicantState = "Applicant_Being_Recruted", username = avm.username, role = avm.role, picture = avm.picture, age = avm.age, arrival = avm.arrival, chanceOfSuccess = avm.chanceOfSuccess, country = avm.country.ToString(), demand = avm.demand, lastname = avm.lastname, name = avm.name, password = avm.password }; HttpClient client = new HttpClient(); client.BaseAddress = new Uri("http://localhost:18080"); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); client.PutAsJsonAsync <applicant>("/l4c_map-v2-web/rest/applicant/", applicant).ContinueWith((postTask) => postTask.Result.EnsureSuccessStatusCode()); return(RedirectToAction("Profile", "Applicant")); }
public ActionResult Application() { var currentUserEmail = User.Identity.Name; if (_db.ApplicantPersons.Any(u => u.EmailAddress == currentUserEmail)) { var applicant = new ApplicantPerson { EmailAddress = User.Identity.Name }; _db.ApplicantPersons.Attach(applicant); _db.Entry(applicant).Property(x => x.EmailAddress).IsModified = true; _db.SaveChanges(); } var familyMembers = _db.sp_ApplicantFamily_SelectFamilyMembers(User.Identity.Name).ToList(); List <ApplicantVm> applicantVmList = new List <ApplicantVm>(); ApplicantVm applicantVm = new ApplicantVm(); foreach (var child in familyMembers) { foreach (var student in applicantVm.studentList) { student.FirstName = child.FirstName; } } return(View(applicantVm)); }
public ActionResult Apply(ApplicantVm applicantVm) { if (ModelState.IsValid) { // do your stuff like: save to database and redirect to required page. //check for current user by email //Set the output parameters ObjectParameter studentId = new ObjectParameter("ApplicantStudentId", typeof(int)); ObjectParameter personId = new ObjectParameter("ApplicantStudentId", typeof(int)); ObjectParameter applicantFatherId = new ObjectParameter("ApplicantFatherId", typeof(int)); ObjectParameter applicantChildId = new ObjectParameter("ApplicantChildId", typeof(int)); ObjectParameter applicantFamilyId = new ObjectParameter("ApplicantFamilyId", typeof(int)); var date = DateTime.Today; //Execute stored procedure to add Father To person table _db.sp_ApplicantPerson_AddPerson(applicantFatherId, applicantChildId, applicantFamilyId, User.Identity.Name, applicantVm.FatherFirstName, applicantVm.Grade, applicantVm.LastName, applicantVm.ChildFirstName, date, applicantVm.ChildGender); // _db.sp_ApplicantStudent_AddStudent(studentId, CreatedId, applicantVm.ChildFirstName, 1); ApplicantParent applicantParent = new ApplicantParent(); } var doc = new Document(); MemoryStream memoryStream = new MemoryStream(); PdfWriter writer = PdfWriter.GetInstance(doc, memoryStream); doc.Open(); doc.Add(new Paragraph("Dear Mr " + applicantVm.LastName + "," + " Congratulations on the acceptance of your son, " + applicantVm.ChildFirstName + " into the " + applicantVm.Grade + " grade" + " we are excited to have " + applicantVm.ChildFirstName + " in our school")); writer.CloseStream = false; doc.Close(); memoryStream.Position = 0; MailMessage mm = new MailMessage("*****@*****.**", applicantVm.EmailAdress) { Subject = " Congratulations on your childs acceptance into school", IsBodyHtml = true, Body = "Dear Mr " + applicantVm.LastName + "," + " <br/>" + " <b>Congratulations </B> on the acceptance of your son, " + applicantVm.ChildFirstName + " into the " + applicantVm.Grade + " grade." + " We are excited to have " + applicantVm.ChildFirstName + " in our school. Attached below is a letter with important information about the upcoming class" }; mm.Attachments.Add(new Attachment(memoryStream, "AcceptanceLetter.pdf")); SmtpClient smtp = new SmtpClient { Host = "smtp.gmail.com", Port = 587, EnableSsl = true, Credentials = new NetworkCredential("*****@*****.**", "Google#400") }; // cc myself MailAddress copy = new MailAddress("*****@*****.**"); mm.Bcc.Add(copy); smtp.Send(mm); return(RedirectToAction("ThankYou", "Application")); }
public new ActionResult Profile(ApplicantVm applicantvm) { var user = (user)Session["user"]; if (user != null && user.role.Equals("Responsable")) { user.id = applicantvm.id; } if (user != null) { HttpClient Client = new HttpClient(); Client.BaseAddress = new Uri("http://localhost:18080"); Client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); HttpResponseMessage response = Client.GetAsync("/l4c_map-v2-web/rest/applicant/" + user.id).Result; if (response.IsSuccessStatusCode) { applicant applicant = response.Content.ReadAsAsync <applicant>().Result; ApplicantVm avm = new ApplicantVm() { id = applicant.id, age = applicant.age, applicantState = applicant.applicantState, chanceOfSuccess = applicant.chanceOfSuccess, country = (PaysVm)Enum.Parse(typeof(PaysVm), applicant.country), lastname = applicant.lastname, name = applicant.name, role = applicant.role, username = applicant.username, picture = applicant.picture, demand = applicant.demand, arrival = applicant.arrival }; ArrivalVm arrivalvm = new ArrivalVm() { arrivalDate = avm.arrival.arrivalDate, idArrival = avm.arrival.idArrival, flightNumber = avm.arrival.flightNumber }; avm.arrivalvm = arrivalvm; Client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); HttpResponseMessage response_test = Client.GetAsync("/l4c_map-v2-web/rest/test/").Result; if (response_test.IsSuccessStatusCode) { ICollection <test> alltest = (ICollection <test>)response_test.Content.ReadAsAsync <IEnumerable <test> >().Result; foreach (test test in alltest) { TestVm tvm = new TestVm() { dateOfPassing = test.dateOfPassing, difficulty = test.difficulty, //files = test.files, //idResponsable = test.idResponsable, idTest = test.idTest, mark = test.mark, name = test.name, specialty = test.specialty, }; Client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); HttpResponseMessage response_question = Client.GetAsync("/l4c_map-v2-web/rest/question/" + test.idTest).Result; ICollection <QuestionVm> allquestion = (ICollection <QuestionVm>)response_question.Content.ReadAsAsync <IEnumerable <QuestionVm> >().Result; foreach (QuestionVm question in allquestion) { tvm.questions.Add(new QuestionVm() { correct = question.correct, idQuestion = question.idQuestion, syn1 = question.syn1, syn2 = question.syn2, syn3 = question.syn3, task = question.task, test = question.test }); } avm.tests.Add(tvm); } Client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); HttpResponseMessage response_testpassed = Client.GetAsync("/l4c_map-v2-web/rest/test/" + user.id).Result; if (response_testpassed.IsSuccessStatusCode) { ICollection <test> testpassed = (ICollection <test>)response_testpassed.Content.ReadAsAsync <IEnumerable <test> >().Result; foreach (test test in testpassed) { avm.testpassed.Add(new TestVm() { dateOfPassing = test.dateOfPassing, difficulty = test.difficulty, idTest = test.idTest, mark = test.mark, name = test.name, specialty = test.specialty }); } } } foreach (var passed in avm.testpassed) { avm.tests.Remove(passed); } return(View(avm)); } } return(RedirectToAction("Error", "Shared")); }