예제 #1
0
        public static SearchOutputWS Search(SearchInfoWS searchInfo)
        {
            if (string.IsNullOrEmpty(searchInfo.Codice) && string.IsNullOrEmpty(searchInfo.Descrizione))
            {
                SearchOutputWS res1 = new SearchOutputWS();
                res1.Code         = SearchOutputCode.KO;
                res1.ErrorMessage = "Inserire un campo di ricerca valido";
                return(res1);
            }
            IEnumerable <DummyElement> temp = null;

            if (string.IsNullOrEmpty(searchInfo.Codice) && !string.IsNullOrEmpty(searchInfo.Descrizione))
            {
                temp = _elements.Values.Where(e => e.Descrizione.ToUpper().Contains(searchInfo.Descrizione.ToUpper()));
            }
            if (!string.IsNullOrEmpty(searchInfo.Codice) && string.IsNullOrEmpty(searchInfo.Descrizione))
            {
                temp = _elements.Values.Where(e => e.Codice.ToUpper().Contains(searchInfo.Codice.ToUpper()));
            }
            if (!string.IsNullOrEmpty(searchInfo.Codice) && !string.IsNullOrEmpty(searchInfo.Descrizione))
            {
                temp = _elements.Values.Where(e => e.Codice.ToUpper().Contains(searchInfo.Codice.ToUpper()) && e.Descrizione.ToUpper().Contains(searchInfo.Descrizione.ToUpper()));
            }
            List <DummyElement> tempList = temp.ToList();
            SearchOutputWS      res      = new SearchOutputWS();

            res.Rows = new List <SearchOutputRowWS>();
            int begin = getBegin(searchInfo.RequestedPage, searchInfo.PageSize, tempList.Count);
            int end   = getEnd(searchInfo.RequestedPage, searchInfo.PageSize, tempList.Count);

            for (int i = begin; i < end; i++)
            {
                DummyElement      el  = tempList[i];
                SearchOutputRowWS row = new SearchOutputRowWS();
                row.Codice      = el.Codice;
                row.Descrizione = el.Descrizione;
                res.Rows.Add(row);
            }
            res.NumTotResults = tempList.Count;
            res.Code          = SearchOutputCode.OK;
            return(res);
        }
예제 #2
0
        public static PuntualSearchOutputWS PuntualSearch(PuntualSearchInfoWS searchInfo)
        {
            PuntualSearchOutputWS res = new PuntualSearchOutputWS();

            if (string.IsNullOrEmpty(searchInfo.Codice.ToUpper()))
            {
                res.Code         = SearchOutputCode.KO;
                res.ErrorMessage = "Il campo di input non ha un valore valido";
                return(res);
            }
            if (_elements.ContainsKey(searchInfo.Codice))
            {
                DummyElement      temp = _elements[searchInfo.Codice];
                SearchOutputRowWS row  = new SearchOutputRowWS();
                row.Codice      = temp.Codice;
                row.Descrizione = temp.Descrizione;
                res.Row         = row;
            }
            res.Code = SearchOutputCode.OK;
            return(res);
        }