Esempio n. 1
0
        public ActionResult AdvSearchCriteria(AdvSearchCriteria model, int?page)
        {
            if (page == null)
            {
                page = JobService.SessionInfo.PageNumber;
            }
            JobService.SessionInfo.PageNumber = page ?? 1;
            //  JobService.SessionInfo.SearchJobId = string.IsNullOrEmpty(model.JobId) ? string.Empty : model.JobId;
            JobService.SessionInfo.Surname       = string.IsNullOrEmpty(model.Surname) ? string.Empty : model.Surname;
            JobService.SessionInfo.Postcode      = string.IsNullOrEmpty(model.Postcode) ? string.Empty : model.Postcode;
            JobService.SessionInfo.PolicyNumber  = string.IsNullOrEmpty(model.PolicyNumber) ? string.Empty : model.PolicyNumber;
            JobService.SessionInfo.TelNo         = string.IsNullOrEmpty(model.TelNo) ? string.Empty : model.TelNo;
            JobService.SessionInfo.ClientCustRef = string.IsNullOrEmpty(model.ClientCustRef) ? string.Empty : model.ClientCustRef;
            JobService.SessionInfo.Address       = string.IsNullOrEmpty(model.Address) ? string.Empty : model.Address;
            //  JobService.SessionInfo.SearchCriteria = string.IsNullOrEmpty(model.Address) ? string.Empty : model.Address;
            var result = customerService.GetCustomersList(model, JobService.SessionInfo.PageNumber);

            result.AdvSearchCriteria = model;
            if (result.TotalRecords == 1)
            {
                // Checking if user push back button on ShowDetails
                if (JobService.IsBackButtonPressed)
                {
                    return(View(model));
                }
                return(RedirectToAction("GoToDetails", new { result.SearchResults[0].CustomerId }));
            }
            ViewBag.OnePageOfJobs = new StaticPagedList <Customer_SearchResult>(result.SearchResults, JobService.SessionInfo.PageNumber, Settings.Default.JobSearchPageSize, result.TotalRecords);
            return(View("AdvSearch", result));
        }
Esempio n. 2
0
        public Job_SearchModel GetJobsListByClientId(AdvSearchCriteria model, int pageNumber)
        {
            var result = new Job_SearchModel();


            result.AdvSearchCriteria = model;
            result.CurrentPage       = pageNumber;

            if (!string.IsNullOrEmpty(model.ServiceId) || !string.IsNullOrEmpty(model.Surname) || !string.IsNullOrEmpty(model.TelNo) || !string.IsNullOrEmpty(model.Postcode) || !string.IsNullOrEmpty(model.PolicyNumber) || !string.IsNullOrEmpty(model.ClientRef) || !string.IsNullOrEmpty(model.Address))
            {
                //Logging
                Log.File.Info(Msg.GenerateLogMsg("Finding jobs... Criteria:"));

                // get products
                var list = Repository.FindJobsByClientId(model.ServiceId, model.Surname, model.Postcode, model.TelNo, model.PolicyNumber, model.ClientRef, model.Address, model.UseAndInWhereCondition.Value, pageNumber, Settings.Default.JobSearchPageSize);

                // if list empty
                if ((list != null) && (list.Count > 0))
                {
                    result.CurrentPage    = pageNumber;
                    result.SearchResults  = list;
                    result.FirstItemIndex = list[0].StartElem;
                    result.TotalRecords   = list[0].ElemCount;
                    result.LastItemIndex  = list[0].LastElem;
                }
            }
            return(result);
        }
Esempio n. 3
0
        public ActionResult Search(int?page)
        {
            if (page == null)
            {
                page = customerService.SessionInfo.PageNumber;
            }
            customerService.SessionInfo.PageNumber = page ?? 1;

            string sc = customerService.SessionInfo.SearchCriteria;

            AdvSearchCriteria model = new AdvSearchCriteria(sc, sc, sc, sc, sc, sc, false);

            var result = customerService.GetCustomersList(model, customerService.SessionInfo.PageNumber);

            result.SearchCriteria = sc;

            // If only one product finded, redirect to details
            if (result.TotalRecords == 1 && !customerService.IsBackButtonPressed)
            {
                if (customerService.SessionInfo.FromIndex)
                {
                    ((ProcessService)Ioc.Get <ProcessService>()).RemoveCurrentProcess();
                }

                return(RedirectToAction("CustomerDetails", new { id = result.SearchResults[0].CustomerId }));
            }
            ViewBag.OnePageOfJobs = new StaticPagedList <Customer_SearchResult>(result.SearchResults, customerService.SessionInfo.PageNumber, Settings.Default.JobSearchPageSize, result.TotalRecords);
            return(View(result));
        }
Esempio n. 4
0
        public ActionResult AdvSearch(int?page)
        {
            if (page == null)
            {
                page = JobService.SessionInfo.PageNumber == 0 ? 1 : JobService.SessionInfo.PageNumber;
            }
            customerService.SessionInfo.PageNumber = page ?? 1;
            Customer_SearchModel modelsession      = new Customer_SearchModel();
            AdvSearchCriteria    AdvSearchCriteria = new AdvSearchCriteria();

            AdvSearchCriteria.Postcode = JobService.SessionInfo.Postcode;

            AdvSearchCriteria.Surname       = JobService.SessionInfo.Surname;
            AdvSearchCriteria.PolicyNumber  = JobService.SessionInfo.PolicyNumber;
            AdvSearchCriteria.ClientCustRef = JobService.SessionInfo.ClientCustRef;
            AdvSearchCriteria.Address       = JobService.SessionInfo.Address;
            AdvSearchCriteria.TelNo         = JobService.SessionInfo.TelNo;


            modelsession.AdvSearchCriteria = AdvSearchCriteria;
            // model.SearchCriteria = JobService.SessionInfo.SearchCriteria;
            //model.CurrentPage = JobService.SessionInfo.PageNumber;
            var model = customerService.GetCustomersList(modelsession.AdvSearchCriteria, customerService.SessionInfo.PageNumber);

            if (model.TotalRecords == 1)
            {
                // Checking if user push back button on ShowDetails
                if (JobService.IsBackButtonPressed)
                {
                    return(View(model));
                }
                return(RedirectToAction("GoToDetails", new { model.SearchResults[0].CustomerId }));
            }
            ViewBag.OnePageOfJobs = new StaticPagedList <Customer_SearchResult>(model.SearchResults, customerService.SessionInfo.PageNumber, Settings.Default.JobSearchPageSize, model.TotalRecords);
            // return RedirectToAction("AdvSearchCriteria", new { model.AdvSearchCriteria, page });
            return(View(model));
        }
Esempio n. 5
0
        public ActionResult AdvSearch(AdvSearchCriteria model, int?page)
        {
            if (page.HasValue)
            {
                customerService.SessionInfo.PageNumber = page.Value;
            }

            if (Request.HttpMethod == "GET" && (customerService.SessionInfo.PageNumber == 0 || customerService.IsBackButtonPressed))
            {
                if (!customerService.IsBackButtonPressed && customerService.SessionInfo.PageNumber == 0)
                {
                    ViewBag.IsGet = true;
                    customerService.SessionInfo.PageNumber = 1;
                    return(View(new Customer_SearchModel()));
                }
                else
                {
                    customerService.SessionInfo.TakeFromSession = true;
                    return(Redirect(Url.Process(PredefinedProcess.CustAdvSearch)));
                }
            }
            else
            {
                if (page.HasValue || customerService.SessionInfo.TakeFromSession)
                {
                    model = new AdvSearchCriteria(
                        customerService.SessionInfo.Surname,
                        customerService.SessionInfo.Postcode,
                        customerService.SessionInfo.ClientCustRef,
                        customerService.SessionInfo.PolicyNumber,
                        customerService.SessionInfo.Address,
                        customerService.SessionInfo.TelNo,
                        true);
                }
                else
                {
                    page = customerService.SessionInfo.PageNumber;
                    customerService.SessionInfo.PageNumber    = page ?? 1;
                    customerService.SessionInfo.Surname       = string.IsNullOrEmpty(model.Surname) ? string.Empty : model.Surname;
                    customerService.SessionInfo.Postcode      = string.IsNullOrEmpty(model.Postcode) ? string.Empty : model.Postcode;
                    customerService.SessionInfo.PolicyNumber  = string.IsNullOrEmpty(model.PolicyNumber) ? string.Empty : model.PolicyNumber;
                    customerService.SessionInfo.TelNo         = string.IsNullOrEmpty(model.TelNo) ? string.Empty : model.TelNo;
                    customerService.SessionInfo.ClientCustRef = string.IsNullOrEmpty(model.ClientCustRef) ? string.Empty : model.ClientCustRef;
                    customerService.SessionInfo.Address       = string.IsNullOrEmpty(model.Address) ? string.Empty : model.Address;
                    model.UseAndInWhereCondition = true;
                }

                var result = customerService.GetCustomersList(model, customerService.SessionInfo.PageNumber);

                result.AdvSearchCriteria = model;

                if (result.TotalRecords == 1 && !customerService.SessionInfo.TakeFromSession)
                {
                    return(RedirectToAction("CustomerDetails", new { id = result.SearchResults[0].CustomerId }));
                }
                else if (result.TotalRecords > 1)
                {
                    ViewBag.OnePageOfJobs = new StaticPagedList <Customer_SearchResult>(result.SearchResults, customerService.SessionInfo.PageNumber, Settings.Default.JobSearchPageSize, result.TotalRecords);
                }

                customerService.SessionInfo.TakeFromSession = false;

                return(View(result));
            }
        }