public async Task Submit(object candidates) // Inserts selected candidates to theory test applications { var Candidates = candidates as List <Candidate>; TheoryTestApplicationsInsertRequest insert_request = new TheoryTestApplicationsInsertRequest(); var instructors_categories = await _instructor_categoriesService.GetAll <List <Instructor_Category> >(request2); InstructorCategoryCandidateSearchRequest request3 = new InstructorCategoryCandidateSearchRequest(); InstructorCategoryCandidateInsertRequest request4 = new InstructorCategoryCandidateInsertRequest(); int count = 0; /* * foreach (var instructor_category in instructors_categories) * { * request3.Instructor_CategoryId = instructor_category.Id; * foreach (var candidate in Candidates) * { * request3.UserId = candidate.Id; * request3.PolozenTeorijskiTest = false; * request3.PolozenTestPrvePomoci = false; * request3.Prijavljen = false; * var instructors_categories_candidates = await _instructor_categories_candidateService.GetAll<List<Instructor_Category_Candidate>>(request3); * foreach (var instructor_category_candidate in instructors_categories_candidates) * { * insert_request.Instructor_Category_CandidateId = instructor_category_candidate.Id; * insert_request.Date = DateTime.Now; * insert_request.FirstAid = !instructor_category_candidate.PolozenTestPrvePomoci; * insert_request.TheoryTest = !instructor_category_candidate.PolozenTeorijskiTest; * insert_request.Status = Status.Inactive; * await _theoryTestApplicationsService.Insert<TheoryTestApplications>(insert_request); * count++; * request4.Instructor_CategoryId = instructor_category_candidate.Instructor_CategoryId; * request4.UserId = instructor_category_candidate.UserId; * request4.PolozenTestPrvePomoci = instructor_category_candidate.PolozenTestPrvePomoci; * request4.PolozenTeorijskiTest = instructor_category_candidate.PolozenTeorijskiTest; * request4.PolozenPrakticniTest = instructor_category_candidate.PolozenPrakticniTest; * request4.NumberOfLessons = instructor_category_candidate.NumberOfLessons; * request4.Paid = instructor_category_candidate.Paid; * request4.Prijavljen = true; * await _instructor_categories_candidateService.Update<Instructor_Category_Candidate>(instructor_category_candidate.Id, request4); * } * } * }*/ foreach (var instructor_category in instructors_categories) { request3.InstructorId = instructor_category.InstructorId; request3.CategoryId = instructor_category.CategoryId; foreach (var candidate in Candidates) { request3.CandidateId = candidate.Id; request3.PolozenTeorijskiTest = false; request3.PolozenTestPrvePomoci = false; request3.Prijavljen = false; var instructors_categories_candidates = await _instructor_categories_candidateService.GetAll <List <Instructor_Category_Candidate> >(request3); foreach (var instructor_category_candidate in instructors_categories_candidates) { insert_request.InstructorId = instructor_category_candidate.InstructorId; insert_request.CategoryId = instructor_category_candidate.CategoryId; insert_request.CandidateId = instructor_category_candidate.CandidateId; insert_request.Date = DateTime.Now; insert_request.FirstAid = !instructor_category_candidate.PolozenTestPrvePomoci; //First Aid znaci da zna da polaze prvu pomoc insert_request.TheoryTest = !instructor_category_candidate.PolozenTeorijskiTest; // Theory Test znaci da zna da polaze i teoriju insert_request.Active = true; await _theoryTestApplicationsService.Insert <TheoryTestApplications>(insert_request); count++; // request4.InstructorId = instructor_category_candidate.InstructorId; // request4.CategoryId = instructor_category_candidate.CategoryId; // request4.CandidateId = instructor_category_candidate.CandidateId; request4.PolozenTestPrvePomoci = instructor_category_candidate.PolozenTestPrvePomoci; request4.PolozenTeorijskiTest = instructor_category_candidate.PolozenTeorijskiTest; request4.PolozenPrakticniTest = instructor_category_candidate.PolozenPrakticniTest; request4.NumberOfLessons = instructor_category_candidate.NumberOfLessons; request4.Paid = instructor_category_candidate.Paid; request4.Prijavljen = true; await _instructor_categories_candidateService.Update <Instructor_Category_Candidate>(instructor_category_candidate.InstructorId, instructor_category_candidate.CategoryId, instructor_category_candidate.CandidateId, request4); } } } await Application.Current.MainPage.DisplayAlert("", "You have successfully submitted " + count + " request", "OK"); }
private async void BtnSave_Click(object sender, EventArgs e) { if (this.ValidateChildren()) { if (_id.HasValue) { var _theory_test_application = await _theory_test_applicationsService.GetById <Model.TheoryTestApplications>(_id); var instructor_category_candidate = await _instructor_categories_candidatesService.GetById <Model.Instructor_Category_Candidate>(_theory_test_application.InstructorId, _theory_test_application.CategoryId, _theory_test_application.CandidateId); var instructorId = instructor_category_candidate.InstructorId; var categoryId = instructor_category_candidate.CategoryId; var candidateId = instructor_category_candidate.CandidateId; InstructorCategoryCandidateInsertRequest updateRequest = new InstructorCategoryCandidateInsertRequest { PolozenTeorijskiTest = checkBoxPolozenTeorijskiIspit.Checked, PolozenTestPrvePomoci = checkBoxPolozenTestPrvePomoci.Checked, PolozenPrakticniTest = instructor_category_candidate.PolozenPrakticniTest, Prijavljen = checkBoxActive.Checked == true ? true : false, NumberOfLessons = instructor_category_candidate.NumberOfLessons, Paid = instructor_category_candidate.Paid, Date = (instructor_category_candidate.Date != null) ? (DateTime?)instructor_category_candidate.Date.Value : null, }; await _instructor_categories_candidatesService.Update <Model.Instructor_Category_Candidate>(instructorId, categoryId, candidateId, updateRequest); TheoryTestApplicationsInsertRequest updateRequest2 = new TheoryTestApplicationsInsertRequest { InstructorId = _theory_test_application.InstructorId, CategoryId = _theory_test_application.CategoryId, CandidateId = _theory_test_application.CandidateId, Active = checkBoxActive.Checked == true ? true : false, Date = _theory_test_application.Date.Date, // TheoryTest = !checkBoxPolozenTeorijskiIspit.Checked, // FirstAid = !checkBoxPolozenTestPrvePomoci.Checked, TheoryTest = _theory_test_application.TheoryTest, FirstAid = _theory_test_application.FirstAid }; await _theory_test_applicationsService.Update <Model.TheoryTestApplications>(_id, updateRequest2); /* * var _theory_test_application = await _theory_test_applicationsService.GetById<Model.TheoryTestApplications>(_id); * TheoryTestApplicationsInsertRequest insert_request = new TheoryTestApplicationsInsertRequest(); * insert_request.InstructorId = _theory_test_application.InstructorId; * insert_request.CategoryId = _theory_test_application.CategoryId; * insert_request.CandidateId = _theory_test_application.CandidateId; * insert_request.Date = _theory_test_application.Date.Date; * Model.Status status; * if (Enum.TryParse(txtStatus.Text, out status)) * { * insert_request.Status = status; * } * insert_request.Status = (Model.Status)cmbStatuses.SelectedIndex; * insert_request.FirstAid = _theory_test_application.FirstAid; * insert_request.TheoryTest = _theory_test_application.TheoryTest; * * var updated = await _theory_test_applicationsService.Update<Model.TheoryTestApplications>(_id, insert_request); * if (updated.Status == Model.Status.Expired) * { * var instructor_category_candidate = await _instructor_categories_candidatesService.GetById<Model.Instructor_Category_Candidate>(updated.InstructorId, updated.CategoryId, updated.CandidateId); * InstructorCategoryCandidateInsertRequest instructorCategoryCandidateInsertRequest = new InstructorCategoryCandidateInsertRequest * { * // Instructor_CategoryId = instructor_category_candidate.Instructor_CategoryId, * // UserId = instructor_category_candidate.UserId, * Prijavljen = false, * PolozenPrakticniTest = instructor_category_candidate.PolozenPrakticniTest, * PolozenTeorijskiTest = instructor_category_candidate.PolozenTeorijskiTest, * PolozenTestPrvePomoci = instructor_category_candidate.PolozenTestPrvePomoci, * NumberOfLessons = instructor_category_candidate.NumberOfLessons, * Paid = instructor_category_candidate.Paid * }; * await _instructor_categories_candidatesService.Update<Model.Instructor_Category_Candidate>(updated.InstructorId, updated.CategoryId, updated.CandidateId, instructorCategoryCandidateInsertRequest); * }*/ } } }