Ejemplo n.º 1
0
        /// <summary>
        /// Method wich convert type SearchDataIn to SerachDataOut
        /// </summary>
        /// <param name="search"></param>
        /// <returns>SearchDataOut</returns>
        public SearchDataOut Parser(SearchDataIn search)
        {
            try
            {
                SearchDataOut sdo = new SearchDataOut();
                sdo.ItemsPerPage = search.ItemsPerPage;
                sdo.CurrentPage  = search.CurrentPage;
                sdo.OrderbyField = search.OrderbyField;
                sdo.OrderBy      = search.OrderByReverse;
                sdo.InstanceName = string.IsNullOrEmpty(search.FilterByFields.InstanceName) ? null : search.FilterByFields.InstanceName;
                sdo.HostName     = string.IsNullOrEmpty(search.FilterByFields.HostName) ? null : search.FilterByFields.HostName;
                sdo.Id           = ConvertToNulable.ToNullableInt(search.FilterByFields.Id);
                sdo.AddedFrom    = ConvertToNulable.ToNullableDateTime(search.FilterByFields.AddedFrom);
                sdo.AddedTo      = ConvertToNulable.ToNullableDateTime(search.FilterByFields.AddedTo);
                sdo.ModifiedFrom = ConvertToNulable.ToNullableDateTime(search.FilterByFields.ModifiedFrom);
                sdo.ModifiedTo   = ConvertToNulable.ToNullableDateTime(search.FilterByFields.ModifiedTo);
                sdo.Status       = ConvertToNulable.ToNullableInt(search.FilterByFields.Status);
                sdo.RAM          = ConvertToNulable.ToNullableInt(search.FilterByFields.RAM);
                sdo.CPUCount     = ConvertToNulable.ToNullableInt(search.FilterByFields.CPUCount);
                sdo.UserName     = string.IsNullOrWhiteSpace(search.FilterByFields.UserName) ? null : search.FilterByFields.UserName;
                sdo.Version      = string.IsNullOrEmpty(search.FilterByFields.Version) ? null : search.FilterByFields.Version;

                return(sdo);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 2
0
        public Query Search <T>(SearchDataOut search)
        {
            Query query = new Query();

            if (search == null)
            {
                throw new ArgumentException();
            }

            query.BuildStoredProcedureName <T>(StoredProcedureConstants.Search);
            query.AddParameters(GetParametersFromObject(search));
            return(query);
        }
Ejemplo n.º 3
0
        public Tuple <int, List <T> > Search(SearchDataOut search)
        {
            Query query = queryBuilder.Search <T>(search);

            using (SqlConnection connection = connectionManager.GetOpenedRepositoryConnection())
            {
                QueryResult result      = queryExecutor.Execute(query, connection);
                int         count       = result.RowCount();
                T           inst        = DataMapper.DataMapper.Map <T>(result);
                List <T>    genericList = DataMapper.DataMapper.MapList <T>(result);
                var         items       = Tuple.Create(count, genericList);
                return(items);
            }
        }