private void Button_Click(object sender, RoutedEventArgs e)
        {
            var aModel = new AModel();

            _vm.MyList.Add(aModel);
            aModel.A = "Hello World";
        }
Example #2
0
 public override bool Delete(AModel aModel)
 {
     DBContext.WriteData("delete from user where `amodel_id` = " + aModel.Id);
     DBContext.WriteData("delete from account where `amodel_id` = " + aModel.Id);
     DBContext.WriteData("delete from amodel where `id` = " + aModel.Id);
     return(true);
 }
Example #3
0
        //12.10创建问题应该写好了

        //需要在问题里面加个标志位表示是否是已经回答isAns=0/1
        //已经在sql里写了
        //12.10回答索引也完成了
        public IActionResult Answer_Index()
        {
            if (HttpContext.Session.GetString("userKind") != "专家")
            {
                return(RedirectToAction("Index", "Login", new { path = "QA /Answer_Index" }));
            }
            var list_q = new List <string>();
            var list_d = new List <string>();
            var list_u = new List <string>();
            var name   = Sql.Read("SELECT ID, detail,id_number FROM OnlineQ WHERE isAns=@0", 0);
            var Con    = 0;

            foreach (DataRow n in name)
            {
                list_u.Add(n[0].ToString());
                list_d.Add(n[1].ToString());
                list_q.Add(n[2].ToString());
                Con++;
            }
            AModel m = new AModel();

            m.ID_user     = list_u;
            m.question    = list_d;
            m.ID_question = list_q;
            m.n           = Con;
            return(View(m));
        }//最好存用户昵称不存ID,加一个查询就行了
Example #4
0
        public IHttpActionResult DoWork()
        {
            int tempId = 0;

            try
            {
                using (var scope = new TransactionScope())
                {
                    var a = new AModel {
                        BValue1 = Guid.NewGuid().ToString()
                    };
                    var b = new BModel {
                        BValue1 = Guid.NewGuid().ToString()
                    };

                    _contextA.ATable.Add(a);
                    _contextA.SaveChanges();

                    tempId = a.Id;
                    throw new Exception();

                    _contextB.BTable.Add(b);
                    _contextB.SaveChanges();

                    scope.Complete();
                }
            }
            catch
            {
                return(Ok($"Id A supposed to get - {tempId}"));
            }
        }
Example #5
0
        static void Main(string[] args)
        {
            ILogger logger = LogManager.GetCurrentClassLogger();

            IUnityContainer unitycontainer = new UnityContainer(); // 建立物件

            unitycontainer.RegisterTypes(
                AllClasses.FromLoadedAssemblies(),
                WithMappings.FromMatchingInterface,
                WithName.Default,
                WithLifetime.Hierarchical);

            unitycontainer.RegisterInstance <ILogger>(logger); // 注入

            IClass1 class1 = unitycontainer.Resolve <IClass1>();

            //IClass class2 = new Class1(logger);

            class1.Log();

            var config = new MapperConfiguration(cfg =>
            {
                cfg.AddProfile <BModelProfile>();
            });

            var mapper = config.CreateMapper();
            var amodel = new AModel
            {
                Name = "Jeff",
                No   = 123
            };
            BModel bmodel = mapper.Map <BModel>(amodel);
        }
Example #6
0
        public AController(App _thisapp, MainWindow _appwindow)
        {
            ThisApp           = _thisapp;
            MyWindow          = _appwindow;
            TheModel          = new AModel();
            BaseDir           = System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
            TheModel.PathName = BaseDir;
            SetRunDate();

            MyWindow.Closing += new CancelEventHandler(MainWClosing);
            CtrlThreadEnable  = true;
            CleanedUp         = false;
            CtrlThreadStarted = false;

            // Add available pages
            PageViewModels.Add(new StartBenchViewModel(this));
            PageViewModels.Add(new WorkBenchViewModel(this));

            CtrlThread = new Thread(new ThreadStart(CtrlThreadFunc));

            CtrlThread.IsBackground = false;
            //Dont call the start of all threads via start of controlthread here.
            //Starting it in the appropriate page via the page's startpagesignal
            //CtrlThread.Start();

            // Set starting page
            CurrentPageViewModel = PageViewModels[0];
        }
Example #7
0
        public TankTurret(Game game, ThePlayer player) : base(game)
        {
            PlayerRef = player;

            Barral    = new AModel(game);
            ShotTimer = new Timer(game, 4.1f);
        }
Example #8
0
 public void ActivateQueuedModel()
 {
     if (m_QueuedModel != null)
     {
         ActiveModel   = QueuedModel;
         m_QueuedModel = null;
     }
 }
Example #9
0
        public void TestTableName()
        {
            AModel model     = new AModel();
            string tableName = RepositoryUtils <AModel> .GetTableNameFromModel(model);

            Assert.IsTrue(!string.IsNullOrEmpty(tableName), "Error the tableName is null");
            Assert.IsTrue(tableName?.Equals("model_exemple"), $"Expected value => model_exemple and received => {tableName}");
        }
Example #10
0
        public HttpResponseMessage Put(int key, AModel item)
        {
            var ret = Request.CreateResponse(System.Net.HttpStatusCode.NoContent);

            Console.WriteLine($"A-item with key '{key}' & '{item.ID}' is updated");
            ret.Headers.Location = Request.RequestUri;
            return(ret);
        }
Example #11
0
 public void ActivateNext()
 {
     if (m_QueuedModel != null)
     {
         Current = Next;
         m_QueuedModel = null;
     }
 }
Example #12
0
 public void ActivateNext()
 {
     if (m_QueuedModel != null)
     {
         Current       = Next;
         m_QueuedModel = null;
     }
 }
Example #13
0
        public IHttpActionResult Get([FromBody] JObject request)
        {
            Repo <User> userRepo = new UserRepo();
            AModel      model    = request.ToObject <User>();
            User        user     = userRepo.Read(model);

            return(Ok(user));
        }
Example #14
0
 /// <summary>
 /// Конструктор для изменения
 /// </summary>
 /// <param name="entity"></param>
 public BaseEditViewModel(AModel <TEntity, TEntityViewModel> entityModel, TEntityViewModel entityViewModel)
 {
     ViewModelSettings = entityViewModel.ViewModelSettings;
     EntityModel       = entityModel;
     Mode = EMode.Edit;
     ContinueButtonName = "Сохранить";
     EntityViewModel    = entityViewModel;
     Initialize(Continue);
 }
        public IHttpActionResult GetAllMessages([FromBody] JObject request)
        {
            AModel      model         = request.ToObject <AModel>();
            Repo <User> userRepo      = new UserRepo();
            User        user          = userRepo.Read(model);
            var         conversations = user.GetConversations();

            return(Ok(conversations));
        }
        public IHttpActionResult GetNewMessages([FromBody] JObject request)
        {
            AModel      model    = request.ToObject <AModel>();
            Repo <User> userRepo = new UserRepo();
            User        user     = userRepo.Read(model);
            var         inbox    = user.Inbox;

            return(Ok(inbox));
        }
Example #17
0
        private static void PrintPageInfo(TextWriter writer, TokenPage page, AModel model)
        {
            var name   = page.Name;
            var scores = model.GetScores(page);

            var maxScore = scores.Max(s => s.Score);
            var label    = scores.First(s => s.Score == maxScore).Type;

            writer.WriteLine($"{name};{label}");
        }
        public void Insert_AddsModelToDbSet()
        {
            unitOfWork.Insert(model);

            AModel actual   = context.ChangeTracker.Entries <Role>().Single().Entity;
            AModel expected = model;

            Assert.Equal(EntityState.Added, context.Entry(model).State);
            Assert.Same(expected, actual);
        }
Example #19
0
        public MultiTargetMapperTests()
        {
            AutoMapper.Mapper.Initialize(config => config.AddProfile <MyProfile>());

            this.Source = new AModel()
            {
                Field1 = "a",
                Field2 = "b"
            };
        }
Example #20
0
        /// <summary>
        /// Конструктор для добавления
        /// </summary>
        public BaseEditViewModel(AModel <TEntity, TEntityViewModel> entityModel, ViewModelSettings viewModelSettings)
        {
            ViewModelSettings = viewModelSettings;
            EntityModel       = entityModel;
            Mode = EMode.Add;
            ContinueButtonName = "Добавить";

            var entity = Activator.CreateInstance <TEntity>();

            EntityViewModel = Activator.CreateInstance(typeof(TEntityViewModel), new object[] { entity, ViewModelSettings }) as TEntityViewModel;
            Initialize(Add);
        }
        public BaseItemsViewModel(AModel <TEntity, TEntityViewModel> entityModel)
        {
            var settingName = typeof(TEntity).Name;

            if (!Program.SettingsInstance.BlockSize.ContainsKey(settingName))
            {
                Program.SettingsInstance.BlockSize.Add(settingName, 100);
            }

            _entityModel = entityModel;
            Initialize();
        }
    public void Test()
    {
        // arrange
        Mapper.CreateMap <AModel, A>();
        var model = new AModel {
            Value = 100
        };
        //act
        var entity = Mapper.Map <A>(model);

        // assert
        entity.Value.Should().Be(100);
        entity.Value.Should().Be(model.Value);
    }
Example #23
0
        public void TestRequestUpdate()
        {
            string id    = Guid.NewGuid().ToString();
            AModel model = new AModel()
            {
                ID   = id,
                Var1 = "Var 1",
                Var2 = "Var 2"
            };

            string request = RepositoryUtils <AModel> .BuildUpdateRequest(model);

            Assert.IsTrue(request.Equals("SET VALUES ( id = @ID , var_1 = @Var1 , var_2 = @Var2 )"));
        }
Example #24
0
        public Gateway(Game game, GameLogic gameLogic) : base(game)
        {
            RefGameLogic = gameLogic;
            HealthBar    = new AModel(game);
            HealthBack   = new AModel(game);

            for (int i = 0; i < 2; i++)
            {
                Doors[i]          = new AModel(game);
                DoorExplosions[i] = new Explode(game);
            }

            LoadContent();
        }
Example #25
0
        public override User Read(AModel aModel)
        {
            DataTable dataTable = DBContext.ReadData("SELECT * FROM	amodel inner join account on amodel.id = account.amodel_id inner join user on amodel.id = user.amodel_id where amodel.id =  " + aModel.Id);
            User      _users    = new User();

            if (dataTable.Rows.Count > 0)
            {
                DataRow dataRow = dataTable.Rows[0];
                _users.Id = UInt64.Parse(dataRow["id"].ToString());
                _users.Credential.Password = dataRow["password"].ToString();
                _users.Credential.Username = dataRow["username"].ToString();
                _users.PhoneNumber         = dataRow["phonenumber"].ToString();
                _users.Avatar         = null; // dataRow["Avatar"].ToString();
                _users.Bio            = dataRow["Bio"].ToString();
                _users.FirstName      = dataRow["FirstName"].ToString();
                _users.LastName       = dataRow["LastName"].ToString();
                _users.LastSeen       = DateTime.Now;      // Datetime.Parse(dataRow["LastSeen"].ToString());
                _users.LastSeenStatus = SeenStatus.Online; // dataRow["LastSeenStatus"].ToString();
            }

            dataTable = DBContext.ReadData(" select * from conversation inner join message on `conversation`.`conversation` = message.conversation_id where `from` <> amodel_id and amodel_id =  " + aModel.Id);
            List <Message> messages = new List <Message>();

            foreach (DataRow dr in dataTable.Rows)
            {
                Message message = new Message()
                {
                    Content      = dr["Content"].ToString(),
                    ReceivedTime = DateTime.Now,
                    SentDateTime = DateTime.Now,
                    Status       = MessageStatus.Sent,
                    Id           = UInt64.Parse(dr["amodel_id"].ToString())
                };

                User from = new User();
                from.Id      = UInt64.Parse(dr["from"].ToString());
                message.From = from;

                User to = new User();
                to.Id      = UInt64.Parse(dr["from"].ToString());
                message.To = to;

                messages.Add(message);
            }

            _users.Inbox = messages;

            return(_users);
        }
        public async Task <IActionResult> Create(AModel model)
        {
            var emptyModel = new AModel();

            if (await TryUpdateModelAsync <AModel>(
                    emptyModel,
                    "",
                    m => m.A1, m => m.A2))
            {
                Context.AModels.Add(emptyModel);
                Context.SaveChanges();
                return(RedirectToAction("List"));
            }

            return(null);
        }
        public async Task <IActionResult> Edit(AModel model)
        {
            var editModel = Context.AModels.SingleOrDefault(m => m.ID == model.ID);

            if (await TryUpdateModelAsync <AModel>(
                    editModel,
                    "",
                    m => m.A1, m => m.A2))
            {
                // Context.AModels.Update(editModel);
                Context.SaveChanges();
                return(RedirectToAction("List"));
            }

            return(null);
        }
Example #28
0
        public static void InitTest()
        {
            var aObj = new AModel
            {
                Age        = 11,
                BirthDate  = DateTime.Now,
                Code       = "123129873",
                Objectives = new string[2] {
                    "1232", "123123"
                }
            };

            var obj   = new AModel();
            var json1 = JSONHelper.Stringify(obj);

            var json = JSONHelper.Stringify(aObj);
        }
Example #29
0
        private void DrawModel(RenderEffectTechniques technique, AModel modelPose, Matrix world, IViewPoint viewPoint)
        {
            var model = modelPose.Model;
            var bones = model.Bones.Count;

            if (SharedBoneMatrix is null || SharedBoneMatrix.Length < bones)
            {
                SharedBoneMatrix = new Matrix[bones];
            }

            model.CopyAbsoluteBoneTransformsTo(SharedBoneMatrix);

            for (var iMesh = 0; iMesh < model.Meshes.Count; iMesh++)
            {
                var mesh = model.Meshes[iMesh];

                for (var iEffect = 0; iEffect < mesh.Effects.Count; iEffect++)
                {
                    var effect = mesh.Effects[iEffect];
                    this.Effect.Wrap(effect);

                    if (modelPose.HasAnimations && RenderEffect.TechniqueSupportsSkinning(technique))
                    {
                        technique = RenderEffect.GetSkinnedTechnique(technique);
                        this.Effect.BoneTransforms = modelPose.SkinTransforms;
                    }

                    this.Effect.TextureOffset         = modelPose.UVOffsets[iMesh];
                    this.Effect.World                 = SharedBoneMatrix[mesh.ParentBone.Index] * world;
                    this.Effect.View                  = viewPoint.View;
                    this.Effect.Projection            = viewPoint.Projection;
                    this.Effect.InverseViewProjection = this.InverseViewProjection;
                    this.Effect.Skybox                = this.Skybox;
                    this.Effect.CameraPosition        = viewPoint.Position;
                    this.Effect.TextureScale          = modelPose.TextureScale;

                    this.Effect.Apply(technique);
                }

                mesh.Draw();
            }
        }
Example #30
0
        public override Account Read(AModel aModel)
        {
            DataTable dataTable = DBContext.ReadData("select * from account where amodel_id = " + aModel.Id);
            Account   _account  = new Account();

            if (dataTable.Rows.Count > 0)
            {
                DataRow dataRow = dataTable.Rows[0];
                _account.Id             = UInt64.Parse(dataRow["user_id"].ToString());
                _account.FirstName      = dataRow["firstname"].ToString();
                _account.LastName       = dataRow["lastname"].ToString();
                _account.Avatar         = null;
                _account.LastSeenStatus = SeenStatus.Online;
                //_account.LastSeen = DateTime.Parse(dataRow["username"].ToString());
                _account.Bio = dataRow["bio"].ToString();
            }


            return(_account);
        }
Example #31
0
        public Paddle(PlayerIndex playerIdx)
        {
            PlayerIdx = playerIdx;

            AModel = new AModel(new Vector3(0, PaddleSize.Y / 2, 0), "Paddle");

            switch (PlayerIdx)
            {
            case PlayerIndex.One:
                AModel.Location = new Vector3(AModel.Location.X + Level.HALF_LEVEL_SIZE_X, AModel.Location.Y, AModel.Location.Z);
                break;

            case PlayerIndex.Two:
                AModel.Location = new Vector3(AModel.Location.X - Level.HALF_LEVEL_SIZE_X, AModel.Location.Y, AModel.Location.Z);
                break;

            default:
                throw new Exception();
            }
        }
Example #32
0
 public AView(AModel parent_model)
 {
     Model = parent_model;
 }