private async void BtnSave_Click(object sender, EventArgs e) { var _driving_test_application = await _driving_test_applicationsService.GetById <Model.DrivingTestApplications>(_id); DrivingTestApplicationsInsertRequest insertRequest = new DrivingTestApplicationsInsertRequest { InstructorId = _driving_test_application.InstructorId, CategoryId = _driving_test_application.CategoryId, CandidateId = _driving_test_application.CandidateId, Date = _driving_test_application.Date.Date, Active = checkBoxActive.Checked == true ? true : false, Passed = checkBoxPolozenPrakticniTest.Checked, }; await _driving_test_applicationsService.Update <Model.DrivingTestApplications>(_id, insertRequest); var instructorId = _driving_test_application.InstructorId; var categoryId = _driving_test_application.CategoryId; var candidateId = _driving_test_application.CandidateId; var instructor_Category_Candidate = await _instructor_categories_candidatesService.GetById <Model.Instructor_Category_Candidate>(instructorId, categoryId, candidateId); InstructorCategoryCandidateInsertRequest instructorCategoryCandidateInsertRequest = new InstructorCategoryCandidateInsertRequest { PolozenTeorijskiTest = instructor_Category_Candidate.PolozenTeorijskiTest, PolozenTestPrvePomoci = instructor_Category_Candidate.PolozenTestPrvePomoci, PolozenPrakticniTest = checkBoxPolozenPrakticniTest.Checked, 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, instructorCategoryCandidateInsertRequest); }
public Model.Instructor_Category_Candidate Insert(InstructorCategoryCandidateInsertRequest request) { var entity = _mapper.Map <Database.Instructor_Category_Candidate>(request); _context.Instructors_Categories_Candidates.Add(entity); _context.SaveChanges(); return(_mapper.Map <Model.Instructor_Category_Candidate>(entity)); }
public IActionResult Insert(InstructorCategoryCandidateInsertRequest request) { try { return(Ok(_service.Insert(request))); } catch (Exception) // vjerovatno je ovog tipa taj exception sto se baci kad je unique constraint violated { // uhvatis specificni exception koji se baci za constraint return(BadRequest("Duplicate user")); // ili neki object po potrebi } }
public async Task Submit(object candidates) { var Candidates = candidates as List <Candidate>; DrivingTestApplicationsInsertRequest insert_request = new DrivingTestApplicationsInsertRequest(); 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.InstructorId = instructor_category.InstructorId; request3.CategoryId = instructor_category.CategoryId; foreach (var candidate in Candidates) { request3.CandidateId = candidate.Id; request3.PolozenTeorijskiTest = true; request3.PolozenTestPrvePomoci = true; request3.PolozenPrakticniTest = 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.Date; insert_request.Passed = false; insert_request.Active = true; await _driving_test_applicationsService.Insert <DrivingTestApplications>(insert_request); count++; request4.PolozenTestPrvePomoci = instructor_category_candidate.PolozenTestPrvePomoci; request4.PolozenTeorijskiTest = instructor_category_candidate.PolozenTeorijskiTest; request4.PolozenPrakticniTest = instructor_category_candidate.PolozenPrakticniTest; request4.Prijavljen = true; request4.NumberOfLessons = instructor_category_candidate.NumberOfLessons; request4.Paid = instructor_category_candidate.Paid; 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"); }
public Model.Instructor_Category_Candidate Update(int instructorId, int categoryId, int candidateId, InstructorCategoryCandidateInsertRequest request) { var entity = _context.Instructors_Categories_Candidates.Where(w => w.InstructorId == instructorId && w.CategoryId == categoryId && w.CandidateId == candidateId).First(); _mapper.Map(request, entity); _context.Instructors_Categories_Candidates.Attach(entity); _context.Instructors_Categories_Candidates.Update(entity); _context.SaveChanges(); return(_mapper.Map <Model.Instructor_Category_Candidate>(entity)); }
public Model.Instructor_Category_Candidate Update(int instructorId, int categoryId, int candidateId, [FromBody] InstructorCategoryCandidateInsertRequest request) { return(_service.Update(instructorId, categoryId, candidateId, request)); }
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); * }*/ } } }