Ejemplo n.º 1
0
        public EntityResponse <T> ExecuteCommandSingleEntity <T>(SZKingdomRequest request, List <SZKingdomArgument> arguments) where T : new()
        {
            EntityResponse <DataTable> response = ExecuteCommand(request, arguments);

            if (!response.IsSuccess)
            {
                return(EntityResponse <T> .Error(response));
            }

            List <T> results = SZKingdomMappingHelper.ReadEntitiesFromTable <T>(response);

            if (results.Count == 0)
            {
                return(EntityResponse <T> .Error(ErrorCode.SZKingdomLibraryNoRecords,
                                                 string.Format(ErrorMessages.SZKingdom_NoResults, request, string.Join("; ", arguments.Select(p =>
                                                                                                                                              string.Format("{0} = {1}", p.Name, p.Value))))));
            }
            if (results.Count > 1)
            {
                return(EntityResponse <T> .Error(ErrorCode.SZKingdomLibraryError,
                                                 string.Format(ErrorMessages.SZKingdom_SingleResultExpected, request, string.Join("; ", arguments.Select(p =>
                                                                                                                                                         string.Format("{0} = {1}", p.Name, p.Value))))));
            }
            return(results.Single());
        }
Ejemplo n.º 2
0
        public EntityResponse <List <T> > ExecuteCommandList <T>(SZKingdomRequest request, List <SZKingdomArgument> arguments) where T : new()
        {
            EntityResponse <DataTable> response = ExecuteCommand(request, arguments);

            if (!response.IsSuccess)
            {
                return(EntityResponse <List <T> > .Error(response));
            }

            List <T> results = SZKingdomMappingHelper.ReadEntitiesFromTable <T>(response);

            return(results);
        }