Exemplo n.º 1
0
        public When_Employer_Searched_Successfully()
        {
            const string query = "Employer";

            _employerService = Substitute.For <IEmployerService>();
            var referralService = Substitute.For <IReferralService>();

            _employerService.Search(query).Returns(new List <EmployerSearchResultDto>
            {
                new EmployerSearchResultDto
                {
                    CompanyName = "CompanyName1",
                    AlsoKnownAs = "AlsoKnownAs1"
                },
                new EmployerSearchResultDto
                {
                    CompanyName = "CompanyName2",
                    AlsoKnownAs = "AlsoKnownAs2"
                }
            });
            var config = new MapperConfiguration(c => c.AddMaps(typeof(EmployerMapper).Assembly));
            var mapper = new Mapper(config);

            var employerController = new EmployerController(_employerService, null, referralService, mapper);

            _result = employerController.SearchEmployer(query);
        }
        public ActionResult AjaxHandler(jQueryDataTableParamModel param)
        {
            string sSearch = "";

            if (param.sSearch != null)
            {
                sSearch = param.sSearch;
            }
            var sortColumnIndex = Convert.ToInt32(Request["iSortCol_0"]);
            var sortDirection   = Request["sSortDir_0"]; // asc or desc
            int iTotalRecords;
            int iTotalDisplayRecords;
            var displayedEmployers = employerService.Search(sSearch, sortColumnIndex, sortDirection, param.iDisplayStart, param.iDisplayLength, out iTotalRecords, out iTotalDisplayRecords);

            var result = from c in displayedEmployers
                         select new[] { c.EmployerId.ToString(), c.Logo, c.EmployerName, (c.City != null ? c.City.CityName.ToString() : string.Empty), c.Email.ToString(), string.Empty };

            return(Json(new
            {
                sEcho = param.sEcho,
                iTotalRecords = iTotalRecords,
                iTotalDisplayRecords = iTotalDisplayRecords,
                aaData = result.ToList()
            },
                        JsonRequestBehavior.AllowGet));
        }
        public IActionResult SearchEmployer(string query)
        {
            var employers = _employerService.Search(query);

            return(Ok(employers.ToList()));
        }