protected async override Task OnInitializedAsync()
        {
            Id        = Id ?? "1";
            Applicant = await ApplicantService.GetApplicant(int.Parse(Id));

            Console.WriteLine(Applicant);
        }
        public ApplicantDomainTest()
        {
            IUnitOfWork unitOfWork            = new UnitOfWork(this._context);
            ILogger <ApplicantService> logger = new Mock <ILogger <ApplicantService> >().Object;

            _applicantService = new ApplicantService(unitOfWork, logger);
        }
Example #3
0
        public void InsertSingleApplicantTest()
        {
            ApplicantService     target = new ApplicantService();     // TODO: Initialize to an appropriate value
            List <ApplicantTemp> app    = new List <ApplicantTemp>(); // TODO: Initialize to an appropriate value

            //List<string> testNo = new List<string>(); // TODO: Initialize to an appropriate value
            string[]   testNo = new string[] { "570247", "570246", "570245", "570244" };
            DateTime[] Edate  = new DateTime[] { Convert.ToDateTime("16/06/2557"), Convert.ToDateTime("26/06/2557"), Convert.ToDateTime("25/06/2557"), Convert.ToDateTime("14/06/2557") };
            string[]   examP  = new string[] { "10111", "10224", "10224", "10224" };
            int        xx     = 4;

            for (int i = 0; i < xx; i++)
            {
                ApplicantTemp ent = new ApplicantTemp();

                //DTO.ApplicantTemp ent = new ApplicantTemp();
                ent.TESTING_NO      = testNo[i];
                ent.TESTING_DATE    = Edate[i];
                ent.EXAM_PLACE_CODE = examP[i];
                ent.APPLY_DATE      = DateTime.Today;
                ent.INSUR_COMP_CODE = "1006";
                ent.USER_ID         = "131101133556905";
                ent.ID_CARD_NO      = "7303043711071";
                ent.RUN_NO          = Convert.ToString(i + 1);
                app.Add(ent);
            }

            string userId = "131101133556905";                                  // TODO: Initialize to an appropriate value
            ResponseService <string> expected = new ResponseService <string>(); // TODO: Initialize to an appropriate value
            ResponseService <string> actual;

            actual = target.InsertSingleApplicant(app, userId);
            Assert.AreEqual("999999570500000865", actual.DataResponse);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }
        public void TestInitializer()
        {
            Url = "https://restcountries.eu/rest/v2/name/{{name}}?fullText=true";

            var applicantRepository = new Mock <IApplicantRepository>();

            _ID       = 1;
            applicant = new Applicant
            {
                Address         = "Address",
                Age             = 20,
                CountryOfOrigin = "Germany",
                EMailAddress    = "*****@*****.**",
                FamilyName      = "James",
                Hired           = true,
                ID   = _ID,
                Name = "Peter"
            };

            applicantRepository.Setup(x => x.GetByID(1)).ReturnsAsync(applicant);

            applicantRepository.Setup(x => x.Create(It.IsAny <Applicant>())).ReturnsAsync((Applicant a) => a);

            applicantRepository.Setup(x => x.Update(It.IsAny <Applicant>())).ReturnsAsync((Applicant a) => a);

            applicantRepository.Setup(x => x.Delete(It.IsAny <Applicant>()));

            var configurationFile = new Mock <IConfigurationFile>();

            configurationFile.Setup(x => x.EuRestCountriesUrl).Returns(Url);

            applicantService = new ApplicantService(applicantRepository.Object, configurationFile.Object);
        }
Example #5
0
        public void GetApplicantByCriteriaTest()
        {
            ApplicantService    target      = new ApplicantService();                     // TODO: Initialize to an appropriate value
            RegistrationType    userRegType = DTO.RegistrationType.OIC;                   // TODO: Initialize to an appropriate value
            string              compCode    = "";                                         // TODO: Initialize to an appropriate value
            string              idCard      = "";;                                        // TODO: Initialize to an appropriate value
            string              testingNo   = string.Empty;                               // TODO: Initialize to an appropriate value
            string              firstName   = string.Empty;                               // TODO: Initialize to an appropriate value
            string              lastName    = string.Empty;                               // TODO: Initialize to an appropriate value
            Nullable <DateTime> startDate   = Convert.ToDateTime("2557/07/04");           // TODO: Initialize to an appropriate value
            Nullable <DateTime> toDate      = Convert.ToDateTime("2557/10/01");           // TODO: Initialize to an appropriate value
            string              paymentNo   = string.Empty;                               // TODO: Initialize to an appropriate value
            string              billNo      = string.Empty;                               // TODO: Initialize to an appropriate value
            int    pageNo             = 1;                                                // TODO: Initialize to an appropriate value
            int    recordPerPage      = 20;                                               // TODO: Initialize to an appropriate value
            bool   Count              = false;                                            // TODO: Initialize to an appropriate value
            string license            = string.Empty;                                     // TODO: Initialize to an appropriate value
            string time               = string.Empty;                                     // TODO: Initialize to an appropriate value
            string examPlaceGroupCode = string.Empty;                                     // TODO: Initialize to an appropriate value
            string examPlaceCode      = string.Empty;                                     // TODO: Initialize to an appropriate value
            string chequeNo           = string.Empty;                                     // TODO: Initialize to an appropriate value
            string examResult         = string.Empty;                                     // TODO: Initialize to an appropriate value
            Nullable <DateTime>       startCandidates = Convert.ToDateTime("2557/05/26"); // TODO: Initialize to an appropriate value
            Nullable <DateTime>       endCandidates   = Convert.ToDateTime("2557/07/04"); // TODO: Initialize to an appropriate value
            ResponseService <DataSet> expected        = null;                             // TODO: Initialize to an appropriate value
            ResponseService <DataSet> actual;

            actual = target.GetApplicantByCriteria(userRegType, compCode, idCard, testingNo, firstName, lastName, startDate, toDate, paymentNo, billNo, pageNo, recordPerPage, Count, license, time, examPlaceGroupCode, examPlaceCode, chequeNo, examResult, startCandidates, endCandidates);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }
        static void Main(string[] args)
        {
            PovertyRates = ApplicantService.GetPovertyData();



            MainMenu.Run();
        }
Example #7
0
        public async Task <ActionResult> LoadTable()
        {
            var applicant = await ApplicantService.GetApplicants();

            var res = Mapper.Map <IEnumerable <Applicant>, IEnumerable <ApplicantFormModel> >(applicant);

            return(View(res));
        }
        internal virtual IApplicantService CreateIApplicantService()
        {
            // TODO: Instantiate an appropriate concrete class.
            ctx = new IAS.DataServices.Test.Mocking.MockIASPersonEntities();
            IApplicantService target = new ApplicantService(ctx);

            return(target);
        }
Example #9
0
        // GET: Home
        public ActionResult Index()
        {
            var applicantService = new ApplicantService();

            if (User.IsInRole("Applicant"))
            {
                RedirectToAction("Create", "Applicant");
            }
            return(View());
        }
Example #10
0
        public void GetApplicantByIdTest()
        {
            ApplicantService          target        = new ApplicantService(); // TODO: Initialize to an appropriate value
            string                    applicantCode = "1";                    // TODO: Initialize to an appropriate value
            string                    testingNo     = "579906";               // TODO: Initialize to an appropriate value
            string                    examPlaceCode = "10111";                // TODO: Initialize to an appropriate value
            ResponseService <DataSet> expected      = null;                   // TODO: Initialize to an appropriate value
            ResponseService <DataSet> actual;

            actual = target.GetApplicantById(applicantCode, testingNo, examPlaceCode);
        }
Example #11
0
        public void GetExamRoomByTestingNoforManageTest()
        {
            ApplicantService target    = new ApplicantService(); // TODO: Initialize to an appropriate value
            string           testingNo = "570279";               // TODO: Initialize to an appropriate value
            string           PlaceCode = "%";                    // TODO: Initialize to an appropriate value
            ResponseService <List <DataItem> > expected = null;  // TODO: Initialize to an appropriate value
            ResponseService <List <DataItem> > actual;

            actual = target.GetExamRoomByTestingNoforManage(testingNo, PlaceCode);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }
        public async Task <ActionResult> Login(LoginViewModel model, string returnUrl)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            // This doesn't count login failures towards account lockout
            // To enable password failures to trigger account lockout, change to shouldLockout: true
            var result = await SignInManager.PasswordSignInAsync(model.Email, model.Password, model.RememberMe, shouldLockout : false);

            switch (result)
            {
            case SignInStatus.Success:
                var user = UserManager.FindById(User.Identity.GetUserId <int>());
                //if (user.Id==1)
                //{
                //    return RedirectToAction("HomeAdmin", "Home");
                //}
                ClientService    cs  = new ClientService();
                ApplicantService aps = new ApplicantService();
                RessourceService rs  = new RessourceService();

                if (rs.RessourceExist(user.Id))
                {
                    return(RedirectToAction("HomeRessource", "Home"));
                }
                else if (aps.ApplicantExist(user.Id))
                {
                    return(RedirectToAction("HomeApplicant", "Home"));
                }
                else if (cs.ClientExist(user.Id))
                {
                    return(RedirectToAction("HomeClient", "Home"));
                }
                else
                {
                    return(RedirectToAction("HomeAdmin", "Home"));
                }

            case SignInStatus.LockedOut:
                return(View("Lockout"));

            case SignInStatus.RequiresVerification:
                return(RedirectToAction("SendCode", new { ReturnUrl = returnUrl, RememberMe = model.RememberMe }));

            case SignInStatus.Failure:
            default:
                ModelState.AddModelError("", "Invalid login attempt.");
                return(View(model));
            }
        }
Example #13
0
        public ActionResult GetApplicantDetail(int id)
        {
            var applicant = ApplicantService.GetApplicantById(id);

            if (applicant == null)
            {
                return(Json(new { model = "failed", modelList = new[] { "Детальної інформації не знайдено!" } }));
            }

            var result = Mapper.Map <Applicant, ApplicantFormModel>(applicant);

            return(Json(new { model = "confirmed", applicant = result }, JsonRequestBehavior.AllowGet));
        }
Example #14
0
        public async Task <ActionResult> DeleteApplicant(BaseFormModel model)
        {
            var applicant = ApplicantService.GetApplicantById(int.Parse(model.Id));

            if (applicant == null)
            {
                return(Json(new { model = "failed", modelList = "Абітурієнта не знайдено!" }, JsonRequestBehavior.AllowGet));
            }

            var result = await ApplicantService.DeleteApplicant(applicant);

            return(Json(new { model = result.Successed ? "confirmed" : "failed", modelList = result.Message, type = "remove" }, JsonRequestBehavior.AllowGet));
        }
        public static void AddApplicant()
        {
            Applicant        applicant  = new Applicant();
            List <Applicant> applicants = new List <Applicant>();

            applicants = ApplicantService.GetApplicantsFromFile();
            Console.Clear();
            Console.Write("Please enter your first name:\t");
            applicant.FirstName = Console.ReadLine();

            while (!Regex.Match(applicant.FirstName, "^[A-Z][a-zA-Z]*$").Success)
            {
                Console.Write("Please enter a valid name:\t");
                applicant.FirstName = Console.ReadLine();
            }
            Console.Write("\nPlease enter your last name:\t");

            applicant.LastName = Console.ReadLine();

            while (!Regex.Match(applicant.LastName, "^[A-Z][a-zA-Z]*$").Success)
            {
                Console.Write("Please enter a valid name:\t");
                applicant.LastName = Console.ReadLine();
            }

            Console.Write("\nTo be eligible for assistance, your zip code must be in the Louisville Metropolitan Statistical Area.\t");
            Console.WriteLine();
            Console.Write("\nPlease Enter your zip code:  ");
            applicant.ZipCode = Console.ReadLine();

            while (ApplicantService.FindZip(applicant.ZipCode) == null)
            {
                Console.Write("You have entered an ineligible zip code.");
                Console.WriteLine();
                Console.Write("The zip code must be one of the following:");
                Console.WriteLine();
                ApplicantService.ShowZips();
                Console.WriteLine();
                Console.Write("Please enter a zip code from the Louisville MSA:  ");
                applicant.ZipCode = Console.ReadLine();
            }

            ApplicantService.GetPRateFromZip(applicant, applicants);


            ApplicantService.SaveApplicant(applicant, applicants);

            applicants.Add(applicant);

            System.Threading.Thread.Sleep(1000);
        }
Example #16
0
        public void GetApplicantFromTestingNoForManageApplicantTest()
        {
            ApplicantService target    = new ApplicantService(); // TODO: Initialize to an appropriate value
            string           TestingNo = "570480";               // TODO: Initialize to an appropriate value
            string           ConSQL    = string.Empty;           // TODO: Initialize to an appropriate value
            int  resultPage            = 0;                      // TODO: Initialize to an appropriate value
            int  PAGE_SIZE             = 0;                      // TODO: Initialize to an appropriate value
            bool Count = false;                                  // TODO: Initialize to an appropriate value
            ResponseService <DataSet> expected = null;           // TODO: Initialize to an appropriate value
            ResponseService <DataSet> actual;

            actual = target.GetApplicantFromTestingNoForManageApplicant(TestingNo, ConSQL, resultPage, PAGE_SIZE, Count);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }
Example #17
0
        public async Task <IActionResult> GetAll(int pageNumber = 1, int perPage = 6)
        {
            if (pageNumber <= 0)
            {
                _logger.LogInformation($"Bad request on get for all applicants by page number {pageNumber}.");

                return(BadRequest(new { message = $"Page number {pageNumber} is invalid " }));
            }
            var applicantService = new ApplicantService(_unitOfWork);
            var applicants       = await applicantService.GetAllApplicants(pageNumber, perPage);

            _logger.LogInformation($"Get request for all applicants.");

            return(applicants.Count == 0 ? Ok(new { message = "No applicants in the database" }) : Ok(applicants));
        }
Example #18
0
        protected async override Task OnInitializedAsync()
        {
            int.TryParse(Id, out int applicantID);
            if (applicantID != 0)
            {
                Applicant = await ApplicantService.GetApplicant(int.Parse(Id));
            }
            else
            {
                Applicant = new Applicant();
            }

            var cc = new CountriesList();

            Countries = cc.GetNames();
        }
Example #19
0
        public async Task <IActionResult> Update(UpdateApplicantDto model, int id)
        {
            model.ApplicantId = id;
            var applicantService = new ApplicantService(_unitOfWork);
            var response         = await applicantService.UpdateApplicant(model);

            if (!response.Success)
            {
                _logger.LogInformation($"Bad request on update of an applicant with id {id}.");

                return(BadRequest(response));
            }
            _logger.LogInformation($"Update request was made by applicant with id ${response.Data.ID}.");

            return(Ok(response));
        }
Example #20
0
        protected async Task HandleValidSubmit()
        {
            Applicant result = null;

            if (Applicant.ID != 0)
            {
                result = await ApplicantService.UpdateApplicant(Applicant);
            }
            else
            {
                result = await ApplicantService.CreateApplicant(Applicant);
            }
            if (result != null)
            {
                NavigationManager.NavigateTo("/");
            }
        }
Example #21
0
        public async Task <ActionResult> SaveApplicant(ApplicantFormModel applicant)
        {
            var data = Mapper.Map <ApplicantFormModel, Applicant>(applicant);
            OperationDetails result;

            // Create or Edit applicant
            if (data.ApplicantId == 0)
            {
                result = await ApplicantService.CreateApplicant(data);

                return(result.Successed ?
                       Json(new { model = "confirmed", modelList = result.Message, applicantId = result.Property }, JsonRequestBehavior.AllowGet) :
                       Json(new { model = "failed", modelList = result.Message }, JsonRequestBehavior.AllowGet));
            }

            result = await ApplicantService.EditApplicant(data);

            return(Json(new { model = result.Successed ? "confirmed" : "failed", modelList = result.Message, type = "save" }, JsonRequestBehavior.AllowGet));
        }
Example #22
0
        public void TestInitializer()
        {
            var applicantRepository = new Mock <IApplicantRepository>();

            applicantRepository.Setup(x => x.GetByID(It.IsAny <Int16>())).ReturnsAsync((Applicant a) => a);

            applicantRepository.Setup(x => x.GetAll()).ReturnsAsync((IEnumerable <Applicant> a) => a);

            applicantRepository.Setup(x => x.Create(It.IsAny <Applicant>())).ReturnsAsync((Applicant a) => a);

            applicantRepository.Setup(x => x.Update(It.IsAny <Applicant>())).ReturnsAsync((Applicant a) => a);

            applicantRepository.Setup(x => x.Delete(It.IsAny <Applicant>()));

            applicantRepository.Setup(x => x.Save());

            var configurationFile = new Mock <IConfigurationFile>();

            applicantService = new ApplicantService(applicantRepository.Object, configurationFile.Object);

            _ID = 1;
        }
Example #23
0
        public ActionResult LoadApplicants(int count)
        {
            // Используем Task.Run, а не await потому что PartialView не умеет работать с Async/Await
            var applicants = Task.Run(() => ApplicantService.GetApplicants()).Result;

            ViewBag.IdName   = "list-applicant";
            ViewBag.SizeList = "18";

            if (count < 1)
            {
                return(PartialView("_PartialDefaultList", new BaseFormModel[] {}));
            }

            if (count > applicants.Count())
            {
                count = applicants.Count();
            }

            applicants = applicants.Skip(applicants.Count() - count);
            var result = Mapper.Map <IEnumerable <Applicant>, IEnumerable <BaseFormModel> >(applicants);

            return(PartialView("_PartialDefaultList", result));
        }
        public static void Run()
        {
            int userInput = 0;


            do
            {
                //get the selection
                userInput = DisplayMenu();


                switch (userInput)
                {
                case 1:     //for a new Applicant; to get their information
                    ApplicantMenu.AddApplicant();
                    break;

                case 2:     //for when an applicant returns; can look up their info using their ID#
                    ApplicantService.RetrieveApplicantInfo();
                    //Remember to provide way for user to exit program again
                    break;

                case 3:
                    Console.WriteLine("Exiting...");
                    System.Threading.Thread.Sleep(2000);
                    break;

                default:
                    Console.Clear();
                    Console.WriteLine();
                    Console.WriteLine(" Error: Invalid Choice");
                    System.Threading.Thread.Sleep(1000);
                    break;
                    //test
                }
            } while (userInput != 3);
        }
Example #25
0
        public async Task <IActionResult> Create([FromBody] CreateApplicantDto model)
        {
            try
            {
                var applicantService = new ApplicantService(_unitOfWork);
                var response         = await applicantService.SaveApplicant(model);

                if (!response.Success)
                {
                    _logger.LogInformation($"Bad request on creation of an applicant with email {model.EmailAddress}.");

                    return(BadRequest(response));
                }
                _logger.LogInformation($"Applicant was created successfully with id {response.Data.ID}.");

                return(Created($"http://localhost:5000/api/user/{response.Data.ID}", response));
            }
            catch (Exception e)
            {
                _logger.LogInformation(e.Message);

                return(StatusCode(500, e.Message));
            }
        }
Example #26
0
        protected async Task Delete_Click()
        {
            await ApplicantService.DeleteApplicant(Applicant.ID);

            NavigationManager.NavigateTo("/");
        }
        public ActionResult Index(string fFile, string returnUrl)
        {
            ApplicationUser user = GetUser();

            if (user == null)
            {
                return(RedirectToAction("Login", "Account"));
            }
            _filename = fFile;
            Guid      userId    = GetUserId();
            Applicant applicant = applicantService.GetApplicant(userId);

            string emailAddress = GetUserEmail();

            if (applicant == null)
            {
                //applicant = appService.CreateApplicant(userId, emailAddress);
                applicant = new Applicant
                {
                    RegisterId         = userId,
                    InternalDatabaseID = Guid.NewGuid(),
                    Email = emailAddress
                };
            }
            else
            {
                applicant.Email = emailAddress;
            }

            if (fFile != null)
            {
                string daxUrl         = WebConfigurationManager.AppSettings["daxtraurl"];
                string daxAccountName = WebConfigurationManager.AppSettings["daxtrausername"];
                string path           = Path.Combine(Server.MapPath("~/resumes"), fFile);
                string hrxml_profile  = ApplicantService.ParseResume(applicant, path);
            }
            if (returnUrl == null)
            {
                if (Session["url"] != null)
                {
                    if (applicant.Id != 0)
                    {
                        returnUrl = Session["url"].ToString();
                        return(Redirect(returnUrl));
                    }
                }
            }
            IEnumerable <SelectListItem> states = AppHelper.GetStateList();
            var         db = new ApplicationDbContext();
            StateLookup state;

            if (!string.IsNullOrWhiteSpace(applicant.State))
            {
                state             = db.StateLookups.Where(a => a.Abbreviation == applicant.State).FirstOrDefault();
                ViewBag.StateList = new SelectList(states, "Value", "Text", state.Id);
                foreach (var item in states)
                {
                    if (item.Text == state.State)
                    {
                        item.Selected = true;
                    }
                }
            }
            else
            {
                ViewBag.StateList = new SelectList(states, "Value", "Text", null);
            }
            return(View(applicant));
        }
Example #28
0
        protected async Task SaveApplicant()
        {
            await ApplicantService.AddApplicant(applicant);

            Modal.Show <ApplicantAcceptModal>("Applicant added");
        }
Example #29
0
        protected async Task SendValid()
        {
            var result = await ApplicantService.CreateApplicant(Applicant);
            //if (result != null)

        }
 protected override async Task OnInitializedAsync()
 {
     Applicants = (await ApplicantService.GetApplicants()).ToList();
 }