Example #1
0
 /// <summary>
 /// Fired when the web application ends
 /// </summary>
 protected virtual void Application_End()
 {
     if (_container != null)
     {
         _container.Dispose();
     }
     ModelDataService.ClearAllEvents();
 }
        //如果要添加额外的条件,可以使用此方法
        //public override JsonResult GetData()
        //{
        //    var jr = base.GetData();
        //    IQueryable<SupplierModel> query = jr.Data as IQueryable<SupplierModel>;

        //    jr.Data = query.Where(t => t.Level >= SupplierLevel.Medium);
        //    return jr;
        //}
        public override JsonResult GetUserDefineList(string prop)
        {
            if (prop == "ContacterId")
            {
                ModelDataService <PersonModel, Person> persons = SiteManager.Get <ModelDataService <PersonModel, Person> >();
                var linked = persons.GetQuery()
                             .Select(p => new
                {
                    id   = p.Id,
                    text = p.Name
                });

                return(Json(linked, JsonRequestBehavior.AllowGet));
            }
            return(base.GetUserDefineList(prop));
        }
Example #3
0
        public void TestLangModelRead()
        {
            //SiteManager.Kernel.Bind<IModelEntityConverter<TestLangTableModel, TestLangTable>>().To<LangTableConveter>();
            //Mapper.CreateMap<TestLangTable, TestLangTableModel>().ForMember(d => d.Remark, opt => opt.MapFrom(s => "RemarkTest"));
            ResHelper.CurrentCultureName = "zh-cn";

            ModelDataService <TestLangTableModel, TestLangTable> langService = new ModelDataService <TestLangTableModel, TestLangTable>(new EFAuditDataService <TestLangTable>(new LangContext()));
            var query = langService.GetQuery().Where(t => t.Name == "张");
            int count = query.Count();
            List <TestLangTableModel> list = query.ToList();

            Assert.IsTrue(count > 0);

            ResHelper.CurrentCultureName = "en-us";
            langService = new ModelDataService <TestLangTableModel, TestLangTable>(new EFAuditDataService <TestLangTable>(new LangContext()));
            query       = langService.GetQuery().Where(t => t.Name == "Zhang");
            list        = query.ToList();
            count       = query.Count();
            Assert.IsTrue(count > 0);
        }
Example #4
0
        public void ShowAutoList()
        {
            // nun greifen wir nicht mehr direkt auf die View zu,
            // sondern nutzen den Navigation Service

            Task.Run(() =>
            {
                // Start des Vorgangs signalisieren
                IsLoading = true;

                // Autoliste neu laden:
                AutoListModel.Autos = ModelDataService.GetAutos();

                // zu Demozwecken eine Sekunde Pause machen...
                Thread.Sleep(1000);

                // Ende des Vorgangs signalisieren
                IsLoading = false;

                // und nun das entsprechende Fenster anzeigen
                NavigationService.Show(AutoListModel);
            });
        }
 public SupplierProductDataInit(ModelDataService <SupplierModel, Supplier> dataProvider)
 {
     _provider = dataProvider;
 }
Example #6
0
 public ModelDataServiceWithDataViewTests()
 {
     _dataProvider = A.Fake <IModelDataProvider <TestDataModel> >();
     _modelFactory = A.Fake <IModelFactory <TestDataModel, TestViewModel> >();
     _dataService  = new ModelDataService <TestDataModel, TestViewModel>(_dataProvider, _modelFactory);
 }
Example #7
0
 public ModelDataServiceTests()
 {
     _dataProvider = A.Fake <IModelDataProvider <TestDataModel> >();
     _dataService  = new ModelDataService <TestDataModel>(_dataProvider);
 }
Example #8
0
 /// <summary>
 /// 多语言组件需要使用ModelDataSerivce,如果不使用ModelDataSerive,在数据保存时可以考虑调用LangDataMapper.SaveLanguages()
 /// 来手动保存表单传递的语言数据, 在数据查询时,可以参考LangDataMapper中的方法来对多语言字段时行手工映射。
 /// </summary>
 /// <param name="dataService"></param>
 public MultiLangDemoController(ModelDataService <StockModel, Stock> dataService)
 {
     _dataService = dataService;
 }