Esempio n. 1
0
        public static T First <T>(this OdooService service, OdooFilter <T> filter) where T : IOdooObject, new()
        {
            var result = service.GetEntities(filter.Filter).ToList();

            if (result.Any())
            {
                return(result.First());
            }
            throw new ArgumentNullException();
        }
Esempio n. 2
0
        public static ICollection <T> List <T>(this OdooService service, OdooFilter <T> filter, OdooSorter <T> sorter = null, int?offset = null, int?limit = null)
            where T : IOdooObject, new()
        {
            if (sorter != null & (offset == null || limit == null))
            {
                throw new ArgumentNullException("sorter", "A sorter requires offset and limit");
            }

            if ((offset != null && limit == null) || (offset == null && limit != null))
            {
                throw new ArgumentNullException("offset", "page and offset are required");
            }

            if (sorter != null)
            {
                return(service.GetEntities(filter.Filter, offset, limit, sorter.Order)
                       .ToList());
            }

            return(service.GetEntities(filter.Filter).ToList());
        }
Esempio n. 3
0
        public static T FirstOrDefault <T>(this OdooService service, OdooFilter <T> filter) where T : IOdooObject, new()
        {
            var result = service.GetEntities(filter.Filter).ToList();

            return(result.FirstOrDefault());
        }