Esempio n. 1
0
        //public override List<TrialMaterial> GenerateData()
        //{
        //    var list = new List<TrialMaterial>();

        //    var trials = dataProvider.GetList(new TrialDataFilter());

        //    if (trials.Count < 1)
        //        return list;

        //    var materials = dataProvider.GetList(new MaterialDataFilter());

        //    Random rand = new Random();

        //    int id = 1;
        //    int materialsCount = materials.Count > 10 ? 10 : materials.Count;
        //    foreach (var trial in trials)
        //    {
        //        HashSet<int> set = rand.NextSet(rand.Next(0, materialsCount + 1), 0, materials.Count);

        //        list.AddRange(set.Select(i => new TrialMaterial
        //            {
        //                Id = id++,
        //                TrialCode = trial.Code,
        //                MaterialId = materials[i].Id
        //            }));

        //        //int count = rand.Next(0, materialsCount + 1);
        //        //HashSet<int> set = new HashSet<int>();
        //        //for (int i = 0; i < count; i++)
        //        //{
        //        //    var materialIndex = rand.Next(0, materials.Count);
        //        //    while (set.Contains(materialIndex))
        //        //    {
        //        //        materialIndex = rand.Next(0, materials.Count); ;
        //        //    }
        //        //    list.Add(new TrialMaterial
        //        //    {
        //        //        Id = id,
        //        //        TrialCode = trial.Code,
        //        //        MaterialId = materials[materialIndex].Id
        //        //    });
        //        //    id++;
        //        //}
        //    }

        //    return list;
        //}

        protected override Func <TrialMaterial, bool> GetFilterFunc(DataFilter <TrialMaterial> filter)
        {
            TrialMaterialDataFilter dataFilter = (TrialMaterialDataFilter)filter;

            return(e =>
                   (dataFilter.TrialCode == null || e.TrialCode == dataFilter.TrialCode) &&
                   (dataFilter.Id == null || e.Id == dataFilter.Id) &&
                   (string.IsNullOrEmpty(dataFilter.MaterialName) || e.Name.Contains(dataFilter.MaterialName)));
        }
        public ActionResult GetTrialMaterialsDict(TrialMaterialDataFilter dataFilter)
        {
            var trialMaterials = DataProvider.GetList(dataFilter);

            return Json(trialMaterials);
        }
        public ActionResult GetTrialMaterialsDict(TrialMaterialDataFilter dataFilter)
        {
            var trialMaterials = DataProvider.GetList(dataFilter);

            return(Json(trialMaterials));
        }
        public ActionResult GetTrialMaterials([DataSourceRequest]DataSourceRequest request, TrialMaterialDataFilter dataFilter)
        {
            var response = DataProvider.GetList(dataFilter);

            return Json(response.ToDataSourceResult(request));
        }
        public ActionResult GetTrialMaterials([DataSourceRequest] DataSourceRequest request, TrialMaterialDataFilter dataFilter)
        {
            var response = DataProvider.GetList(dataFilter);

            return(Json(response.ToDataSourceResult(request)));
        }