public ServiceParishObject StandardSearch(ParishSearchFilter parishSearchFilter,DataShaping shaper, IValidator validator = null)
        {
            if (validator != null)
                _validator = validator;

            var serviceParishObject = new ServiceParishObject();

            string retVal = "";

            try
            {

                serviceParishObject.serviceParishs = _parishsDal.GetParishByFilter(parishSearchFilter, shaper);
                serviceParishObject.Batch = shaper.RecordStart;
                serviceParishObject.BatchLength = shaper.RecordPageSize;
                serviceParishObject.Total = shaper.TotalRecords;

                serviceParishObject.serviceParishs = serviceParishObject.serviceParishs;

            }
            catch (Exception ex1)
            {
                retVal = "Exception: " + ex1.Message;
            }
            finally
            {
                if (retVal != "") retVal += Environment.NewLine;

                serviceParishObject.ErrorStatus = retVal;
            }

            return serviceParishObject;
        }
        public List<string> GetParishNames(ParishSearchFilter parishSearchFilter, IValidator validator = null)
        {
            if (parishSearchFilter.ParishIds.IsNullOrBelowMinSize()) return new List<string>();

            return _parishsDal.GetParishNames(parishSearchFilter.ParishIds);
        }
Example #3
0
        public List<ServiceParish> GetParishByFilter(ParishSearchFilter parishSearchFilter, DataShaping dataShaping)
        {
            using (var context = new GeneralModelContainer())
            {
                IQueryable<Parish> parishDataTable;

                if (parishSearchFilter.Name == "%" && parishSearchFilter.Deposited == "%" &&
                    parishSearchFilter.County == "%")
                {
                    parishDataTable = context.Parishs;
                }
                else
                {
                    parishSearchFilter.Name = parishSearchFilter.Name.Replace('%', ' ').Trim();
                    parishSearchFilter.Deposited = parishSearchFilter.Deposited.Replace('%', ' ').Trim();
                    parishSearchFilter.County = parishSearchFilter.County.Replace('%', ' ').Trim();

                    parishDataTable =
                        context.Parishs.Where(o => o.ParishName.Contains(parishSearchFilter.Name) &&
                                                          o.ParishRegistersDeposited.Contains(
                                                              parishSearchFilter.Deposited) &&
                                                          o.ParishCounty.Contains(parishSearchFilter.County));
                }

                dataShaping.TotalRecords = parishDataTable.Count();

                return
                    parishDataTable.OrderBy(o => o.ParishName)
                        .Skip(dataShaping.RecordStart*dataShaping.RecordPageSize)
                        .Take(dataShaping.RecordPageSize)
                        .Select(p => new ServiceParish
                        {
                            ParishCounty = p.ParishCounty,
                            ParishDeposited = p.ParishRegistersDeposited,
                            ParishId = p.ParishId,
                            ParishEndYear = p.ParishEndYear,
                            ParishStartYear = p.ParishStartYear,
                            ParishName = p.ParishName,
                            ParishParent = p.ParentParish,
                            ParishNote = p.ParishNotes

                        }).ToList();
            }
            //serviceParishObject.serviceParishs.Skip(shaper.RecordStart * shaper.RecordPageSize).Take(shaper.RecordPageSize).ToList();
        }
        public IHttpActionResult GetParishs(string deposited, string name, string county, string pno, string psize, string sortcol)
        {
            //string pno, string psize, string sortcol = ""
            string retVal = "";

            var psf = new ParishSearchFilter
            {
                County = county ?? "",
                Deposited = deposited?? "",
                Name = name??""
            };

            var result = new ServiceParishObject();

            try
            {
                result = _parishSearch.StandardSearch(psf, new DataShaping() { RecordPageSize = psize.ToInt32(), RecordStart = pno.ToInt32(), Column = sortcol });
            }
            catch (Exception ex1)
            {
                retVal = ex1.Message;
            }

            if (retVal != "")
            {
                return Content(HttpStatusCode.BadRequest, retVal);
            }

            return Ok(result);
        }
        public IHttpActionResult GetParishNames(string parishIds)
        {
            var parishs = new List<string>();

            string retVal = "";

            try
            {
                var psf = new ParishSearchFilter()
                {
                    ParishIds = parishIds.ParseToGuidList()
                };

                parishs = _parishSearch.GetParishNames(psf);
            }
            catch (Exception ex1)
            {
                retVal = ex1.Message;
            }

            if (retVal != "")
            {
                return Content(HttpStatusCode.BadRequest, retVal);
            }

            return Ok(parishs);
        }
        // parishs
        public ServiceParishObject GetParishs(string deposited, string name, string county, string page_number, string page_size, string sort_col)
        {
            var psf =new ParishSearchFilter
            {
                County = county,
                Deposited = deposited,
                Name = name
            };

            return _parishSearch.StandardSearch(psf, new DataShaping() { RecordPageSize = page_size.ToInt32(), RecordStart = page_number.ToInt32() });
        }