Exemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="userName"></param>
        /// <param name="currentUserName"></param>
        /// <param name="appID"></param>
        /// <param name="overrideID"></param>
        /// <param name="searchCriteria"></param>
        /// <param name="page"></param>
        /// <param name="pageSize"></param>
        /// <param name="includeInActive"></param>
        /// <param name="dataRepository"></param>
        /// <param name="uow"></param>
        /// <returns></returns>
        public CommandSearchMatchResultsDC SearchCommand(string userName, string currentUserName, string appID, string overrideID, CommandSearchCriteriaDC searchCriteria, int page, int pageSize, bool includeInActive, IRepository <Command> dataRepository, IUnitOfWork uow)
        {
            try
            {
                using (uow)
                {
                    // Build specification for search
                    ISpecification <Command> specification = null;
                    if (!includeInActive)
                    {
                        specification = new Specification <Command>(x => x.IsActive == true);
                    }

                    // Find all items that satisfy the specification created above.
                    IEnumerable <Command> dataEntities = dataRepository.Find(specification, x => new { x.Code /*change field*/ }, page, pageSize);

                    // Get total count of items for search critera
                    int itemCount = dataRepository.Find(specification).Count();

                    CommandSearchMatchResultsDC results = new CommandSearchMatchResultsDC();

                    // Convert to data contracts
                    List <CommandSearchMatchDC> destinations = Mapper.Map <IEnumerable <Command>, List <CommandSearchMatchDC> >(dataEntities);

                    results.CommandList = destinations;

                    return(results);
                }
            }
            catch (Exception e)
            {
                //Prevent exception from propogating across the service interface
                ExceptionManager.ShieldException(e);

                return(null);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="userName"></param>
        /// <param name="currentUserName"></param>
        /// <param name="appID"></param>
        /// <param name="overrideID"></param>
        /// <param name="searchCriteria"></param>
        /// <param name="page"></param>
        /// <param name="pageSize"></param>
        /// <param name="includeInActive"></param>
        /// <returns></returns>
        public CommandSearchMatchResultsDC SearchCommand(string userName, string currentUserName, string appID, string overrideID, CommandSearchCriteriaDC searchCriteria, int page, int pageSize, bool includeInActive)
        {
            IUnitOfWork uow = new UnitOfWork();

            IRepository <Command> dataRepository = new Repository <Command>(uow.ObjectContext, userName, currentUserName, appID, overrideID);

            return(SearchCommand(userName, currentUserName, appID, overrideID, searchCriteria, page, pageSize, includeInActive, dataRepository, uow));
        }