Beispiel #1
0
        public List <Model.Instructor_Category_Candidate> GetAll(InstructorCategoryCandidateSearchRequest request)
        {
            var query = _context.Instructors_Categories_Candidates.AsQueryable();

            //Return all selected candidates of logged in instructor for theory test applications
            if (request != null && request.InstructorId != 0 && request.CategoryId != 0 && request.CandidateId != 0 && (request.PolozenTeorijskiTest == false || request.PolozenTestPrvePomoci == false) && request.Prijavljen == false)
            {
                query = query.Where(q => q.InstructorId == request.InstructorId && q.CategoryId == request.CategoryId && q.CandidateId == request.CandidateId && (q.PolozenTeorijskiTest == request.PolozenTeorijskiTest || q.PolozenTestPrvePomoci == request.PolozenTestPrvePomoci) && q.Prijavljen == request.Prijavljen).Include(i => i.Instructor_Category).ThenInclude(i => i.Category);
            }

            //Returns all candidates of logged in instructor for theory test applications
            else if (request != null && request.InstructorId != 0 && request.CategoryId != 0 && (request.PolozenTeorijskiTest == false || request.PolozenTestPrvePomoci == false) && request.Prijavljen == false)
            {
                query = query.Where(w => w.InstructorId == request.InstructorId && w.CategoryId == request.CategoryId && (w.PolozenTeorijskiTest == request.PolozenTeorijskiTest || w.PolozenTestPrvePomoci == request.PolozenTestPrvePomoci) && w.Prijavljen == request.Prijavljen).Include(i => i.Instructor_Category).ThenInclude(i => i.Category);
            }

            //Selects candidates (candidates who are assigned to logged in instructor) who have passed theory test
            else if (request != null && request.InstructorId != 0 && request.CategoryId != 0 && request.PolozenTeorijskiTest == true && request.PolozenTestPrvePomoci == true && request.PolozenPrakticniTest == false && request.Prijavljen == false)
            {
                query = query.Where(z => z.InstructorId == request.InstructorId && z.CategoryId == request.CategoryId && z.PolozenTeorijskiTest == request.PolozenTeorijskiTest && z.PolozenTestPrvePomoci == request.PolozenTestPrvePomoci && z.PolozenPrakticniTest == request.PolozenPrakticniTest && z.Prijavljen == request.Prijavljen).Include(i => i.Instructor_Category).ThenInclude(i => i.Category);
            }
            else if (request != null && request.Paid == false)
            {
                query = query.Where(p => p.Paid == request.Paid).Include(i => i.Instructor_Category).ThenInclude(i => i.Category);
            }
            var list = query.ToList();

            return(_mapper.Map <List <Model.Instructor_Category_Candidate> >(list));
        }
        // public ICommand SubmitCommand { get; set; }

        public async Task Init() // Displays list of candidates of logged in instructor for theory test applications
        {
            if (CandidatesList.Count > 0)
            {
                CandidatesList.Clear();
            }
            request.Username = APIService.Username;
            var instructors = await _instructorsService.GetAll <List <Instructor> >(request);

            var instructor = instructors[0];            // Returns logged in instructor

            /*
             * request2.UserId = instructor.Id;
             * var instructors_categories = await _instructor_categoriesService.GetAll<List<Instructor_Category>>(request2); // Returns all categories of logged in instructor
             *
             * InstructorCategoryCandidateSearchRequest request3 = new InstructorCategoryCandidateSearchRequest();
             * request3.PolozenTeorijskiTest = false;
             * request3.PolozenTestPrvePomoci = false;
             * request3.Prijavljen = false;
             * foreach (var instructor_category in instructors_categories)
             * {
             *  request3.Instructor_CategoryId = instructor_category.Id;
             *  var instructors_categories_candidates = await _instructor_categories_candidateService.GetAll<List<Instructor_Category_Candidate>>(request3); // Returns all users of logged in instructors and all categories of that instructor
             *  foreach (var instructor_category_candidate in instructors_categories_candidates)
             *  {
             *      int category_id = instructor_category_candidate.Instructor_Category.CategoryId;
             *      var category = await _categoriesService.GetById<Category>(category_id);
             *      var candidate = await _candidatesService.GetById<Candidate>(instructor_category_candidate.UserId);
             *      candidate.candidate_category = candidate.FirstName + " " + candidate.LastName + " " + "(" + category.Name + ")";
             *      CandidatesList.Add(candidate);
             *  }
             * }*/

            request2.InstructorId = instructor.Id;
            var instructors_categories = await _instructor_categoriesService.GetAll <List <Instructor_Category> >(request2); //Returns all categories of logged in instructor

            InstructorCategoryCandidateSearchRequest request3 = new InstructorCategoryCandidateSearchRequest();

            request3.PolozenTeorijskiTest  = false;
            request3.PolozenTestPrvePomoci = false;
            request3.Prijavljen            = false;
            foreach (var instructor_category in instructors_categories)
            {
                request3.InstructorId = instructor_category.InstructorId;
                request3.CategoryId   = instructor_category.CategoryId; // Ovo ovdje je opcionalno
                var instructors_categories_candidates = await _instructor_categories_candidateService.GetAll <List <Instructor_Category_Candidate> >(request3);

                foreach (var instructor_category_candidate in instructors_categories_candidates)
                {
                    var candidate = await _candidatesService.GetById <Candidate>(instructor_category_candidate.CandidateId);

                    candidate.candidate_category = candidate.candidate + " " + "(" + instructor_category_candidate.Instructor_Category.Category.Name + ")";
                    CandidatesList.Add(candidate);
                }
            }
        }
        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");
        }
Beispiel #4
0
        public async Task Init()
        {
            search_request1.Username = APIService.Username;
            var instructors = await _instructorsService.GetAll <List <Instructor> >(search_request1);

            var instructor = instructors[0];            // Returns logged in instructor

            InstructorCategorySearchRequest search_request2 = new InstructorCategorySearchRequest();

            search_request2.InstructorId = instructor.Id;
            var instructors_categories = await _instructor_categoriesService.GetAll <List <Instructor_Category> >(search_request2); // Returns all categories of logged in instructor

            InstructorCategoryCandidateSearchRequest search_request3 = new InstructorCategoryCandidateSearchRequest();

            search_request3.PolozenTeorijskiTest  = true;
            search_request3.PolozenTestPrvePomoci = true;
            search_request3.PolozenPrakticniTest  = false;
            search_request3.Prijavljen            = false;
            search_request3.InstructorId          = instructor.Id;
            foreach (var instructor_category in instructors_categories)
            {
                //search_request3.Instructor_CategoryId = instructor_category.Id;
                search_request3.CategoryId = instructor_category.CategoryId;
                var instructors_categories_candidates = await _instructor_categories_candidateService.GetAll <List <Instructor_Category_Candidate> >(search_request3); // Returns all users of logged in instructors and all categories of that instructor

                foreach (var instructor_category_candidate in instructors_categories_candidates)
                {
                    var candidate = await _candidatesService.GetById <Candidate>(instructor_category_candidate.CandidateId);

                    candidate.category           = instructor_category_candidate.Instructor_Category.Category.Name;
                    candidate.candidate_category = candidate.candidate + " " + "(" + candidate.category + ")";
                    CandidatesList.Add(candidate);
                }
            }

            VehicleSearchRequest vehicle_search_request = new VehicleSearchRequest();
            var vehicles = await _vehiclesService.GetAll <List <Vehicle> >(null);

            foreach (var vehicle in vehicles)
            {
                vehicle.vehicle = vehicle.Model.Name + " " + "(" + vehicle.RegistrationNumber + ")";
                VehiclesList.Add(vehicle);
            }
        }
        public async Task Init() // Displays list of candidates of logged in instructor for driving test applications
        {
            if (CandidatesList.Count > 0)
            {
                CandidatesList.Clear();
            }
            request.Username = APIService.Username;
            var instructors = await _instructorsService.GetAll <List <Instructor> >(request);

            var instructor = instructors[0];            // Returns logged in instructor


            request2.InstructorId = instructor.Id;
            var instructors_categories = await _instructor_categoriesService.GetAll <List <Instructor_Category> >(request2); // Returns all categories of logged in instructor

            InstructorCategoryCandidateSearchRequest request3 = new InstructorCategoryCandidateSearchRequest();

            request3.PolozenTeorijskiTest  = true;
            request3.PolozenTestPrvePomoci = true;
            request3.PolozenPrakticniTest  = false;
            request3.Prijavljen            = false;
            foreach (var instructor_category in instructors_categories)
            {
                request3.InstructorId = instructor_category.InstructorId;
                request3.CategoryId   = instructor_category.CategoryId;
                var instructors_categories_candidates = await _instructor_categories_candidateService.GetAll <List <Instructor_Category_Candidate> >(request3); // Returns all users of logged in instructors and all categories of that instructor

                foreach (var instructor_category_candidate in instructors_categories_candidates)
                {
                    var candidate = await _candidatesService.GetById <Candidate>(instructor_category_candidate.CandidateId);

                    candidate.candidate_category = candidate.candidate + " " + "(" + instructor_category_candidate.Instructor_Category.Category.Name + ")";
                    CandidatesList.Add(candidate);
                }
            }
        }
 public IList <Model.Instructor_Category_Candidate> GetAll([FromQuery] InstructorCategoryCandidateSearchRequest request)
 {
     return(_service.GetAll(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");
        }