Ejemplo n.º 1
0
		GridModel[] Read(DextopReadFilter filter)
		{
			return new[] {
                new GridModel { Id = 1, Name = "Bill", Age = 30, Height=180 },
                new GridModel { Id = 2, Name = "Bob", Age = 26, Height=175 }               
            };
		}       
Ejemplo n.º 2
0
        IEnumerable<ComboModel> GetValues3(DextopReadFilter filter)
        {
            var baseValue = filter.Params.SafeGet("Value2", 0);

            for (var i = baseValue+1; i < 10; i++)
                yield return new ComboModel { Id = i };
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Creates the paged result by reading the IQueryable source.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="source">The source.</param>
        /// <param name="filter">The filter.</param>
        /// <param name="fastTotal">Indicates that N+1 paging is used.</param>
        /// <returns></returns>
        public static DextopReadResult <T> CreatePage <T>(IQueryable <T> source, DextopReadFilter filter, bool fastTotal = false) where T : class
        {
            if (filter == null)
            {
                throw new ArgumentNullException("filter");
            }

            source = ApplySort(source, filter);

            if (filter.limit.HasValue)
            {
                int limit = filter.GetLimit();
                int start = filter.GetStart();
                if (fastTotal)
                {
                    var data = source.Skip(start).Take(limit + 1).ToArray();
                    return(Create(data.Take(limit).ToArray(), start + data.Length));
                }
                else
                {
                    return(Create(source.Skip(start).Take(limit).ToArray(), source.Count()));
                }
            }
            return(Create(source.ToArray()));
        }
Ejemplo n.º 4
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="filter"></param>
 /// <returns></returns>
 public DextopReadResult <T> Read(DextopReadFilter filter)
 {
     if (Paging)
     {
         return(DextopReadResult.CreatePage(data.Values.AsQueryable(), filter));
     }
     return(DextopReadResult.Sort(data.Values.AsQueryable(), filter));
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Creates the result by sorting end enumerating the specified source.
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="source">The source.</param>
 /// <param name="filter">The filter.</param>
 /// <returns></returns>
 public static DextopReadResult <T> Sort <T>(IQueryable <T> source, DextopReadFilter filter) where T : class
 {
     if (filter == null)
     {
         throw new ArgumentNullException("filter");
     }
     source = ApplySort(source, filter);
     return(Create(source.ToArray()));
 }
Ejemplo n.º 6
0
        CurrencyHistoryRate[] LoadHistory(DextopReadFilter filter)
        {
            String iso;
            filter.Params.TryGet<String>("ISOCode", out iso);
            var baseCurency = filter.Params.SafeGet<String>("BaseCurrencyISOCode", "EUR");

            if (baseCurency == "EUR")
                return CurrencyHistoryDataProvider.GetCurrencyRateHistory(iso);
            else
                return CurrencyHistoryDataProvider.GetCurrencyRateComparisionHistory(iso, baseCurency);
        }
Ejemplo n.º 7
0
        RateModel[] Load(DextopReadFilter filter)
        {
            var currency = filter.Params.SafeGet("Currency", "EUR");
            var amount = filter.Params.SafeGet("Amount", 100.0m);

            var data = CurrencyDataProvider.GetCurrencyList(currency);
            return data.Rates.Select(a => new RateModel
            {
                Currency = a.Currency,
                ISOCode = a.ISOCode,
                Rate = a.Rate,
                Amount = amount * a.Rate
            }).ToArray();
        }
Ejemplo n.º 8
0
        RemoteLookupModel[] RemoteLookup(DextopReadFilter filter)
        {
            String query = filter.Params.SafeGet<String>("query");

            var data = new [] {
                new RemoteLookupModel { Code = "Red", Description = "Code Red"},
                new RemoteLookupModel { Code = "Blue", Description = "Code Blue"},
                new RemoteLookupModel { Code = "Green", Description = "Code Green"},
            };

            if (String.IsNullOrWhiteSpace(query))
                return data;

            return data.Where(a => a.Code.StartsWith(query) || a.Description.Contains(query)).ToArray();
        }
Ejemplo n.º 9
0
        static IQueryable <T> ApplySort <T>(IQueryable <T> source, DextopReadFilter filter) where T : class
        {
            if (filter == null)
            {
                return(source);
            }

            if (filter.sort != null && filter.sort.Length > 0)
            {
                var  sorter = filter.sort[0];
                bool asc    = IsAscendingDirection(sorter.direction);
                source = source.OrderBy(sorter.property, asc);
                for (var i = 1; i < filter.sort.Length; i++)
                {
                    sorter = filter.sort[i];
                    asc    = IsAscendingDirection(sorter.direction);
                    source = source.ThenBy(sorter.property, asc);
                }
            }

            return(source);
        }
Ejemplo n.º 10
0
 DextopReadResult IDextopReadProxy.Read(DextopReadFilter options)
 {
     return(proxy.Read(options));
 }
Ejemplo n.º 11
0
 /// <summary>
 /// Reads the data using specified filter.
 /// </summary>
 /// <param name="filter">The filter.</param>
 /// <returns></returns>
 public DextopReadResult <T> Read(DextopReadFilter filter)
 {
     return(d(filter));
 }
Ejemplo n.º 12
0
 Stock[] Load(DextopReadFilter filter)
 {
     var data = StockDataProvider.GetStockData();
     return data.ToArray();
 }
Ejemplo n.º 13
0
		GridModel[] Read(DextopReadFilter filter)
		{
            return new[] {
                new GridModel { Id = 1, Date = DateTime.Today, Bool = true, Time = DateTime.Now.TimeOfDay, Tooltip = "Hover", TooltipField = "Leave me alone!"}
            };
		}       
Ejemplo n.º 14
0
 DextopReadResult IDextopReadProxy.Read(DextopReadFilter filter)
 {
     return(proxy.Read(filter));
 }
Ejemplo n.º 15
0
 /// <summary>
 /// Read records using the specified filter.
 /// </summary>
 /// <param name="filter">The filter.</param>
 /// <returns>Read result.</returns>
 public abstract DextopReadResult <T> Read(DextopReadFilter filter);
Ejemplo n.º 16
0
		DextopReadResult<GridModel> Read(DextopReadFilter filter)
		{
			return DextopReadResult.CreatePage(data.AsQueryable(), filter);
		}