public OperationActionRelationWindow(OperationActionInfoModel entity, OperationAction operationAction,IUserOperationDAL userOperationDAL)
    : this(userOperationDAL)
 {
     UserAction = operationAction;
     InitData(entity);
     InitControl();
 }
 private void InitData(OperationActionInfoModel entity)
 {
     TxtActionDisplayName.Text = entity.ActionDisplayName;
     TxtActionName.Text = entity.ActionName;
     TxtWorkflowName.Text = entity.WorkflowName;
     TxtWorkflowDisplayName.Text = entity.WorkflowDisplayName;
     InitProperty(entity);
     ExistUserRoleList = UserOperationDAL.QueryAllRoleByActionId(entity.Id);
     LvUserRole.Items.Clear();
     LvUserRole.ItemsSource = ExistUserRoleList;
 }
 public void TestOperationActionInfoCreateTable()
 {
     var entity = new OperationActionInfoModel { ActionDisplayName = "ActionDisplayName", ActionName = "ActionDisplayName", CreateDateTime = DateTime.Now, Id = Guid.NewGuid().ToString(), LastUpdateDateTime = DateTime.Now };
     OperationActionInfoModel result; 
     using (var session= sessions.OpenSession())
     {
         session.Save(entity);
         session.Flush();
         result = session.Get<OperationActionInfoModel>(entity.Id);
     }
     Assert.AreEqual(entity.ActionDisplayName,result.ActionDisplayName);
 }
        public void TestOperationActionInfoQueryAll()
        {
            var insertEntity = new OperationActionInfoModel { ActionDisplayName = "Modify", ActionName = "Modify", WorkflowName = "WorkflowName", WorkflowDisplayName = "WorkflowDisplayName", CreateDateTime = DateTime.Now, Id = Guid.NewGuid().ToString(), LastUpdateDateTime = DateTime.Now };

            using (var session = sessions.OpenSession())
            {
                session.Save(insertEntity);
                session.Flush();
                ICriteria crit = session.CreateCriteria(typeof(OperationActionInfoModel));
                var entityList = crit.List();
                var resultList = session.CreateQuery("from OperationActionInfoModel ").List<OperationActionInfoModel>();
                Assert.AreEqual(entityList.Count,resultList.Count);
            }
        }
       public void TestOperationActionInfoDelete()
       {
           var insertEntity = new OperationActionInfoModel { ActionDisplayName = "Modify", ActionName = "Modify", WorkflowName = "WorkflowName", WorkflowDisplayName = "WorkflowDisplayName", CreateDateTime = DateTime.Now, Id = Guid.NewGuid().ToString(), LastUpdateDateTime = DateTime.Now };
 
           using (var session = sessions.OpenSession())
           {
               session.Save(insertEntity);
               session.Flush();
               ICriteria crit = session.CreateCriteria(typeof(OperationActionInfoModel));
               var entity = crit.List<OperationActionInfoModel>().First();
               session.Delete(entity);
               session.Flush();
               var result = session.Get<OperationActionInfoModel>(entity.Id);
               Assert.IsNull(result);
           }
       }
 public void TestOperationActionInfoModify()
 {
     var entity = new OperationActionInfoModel { ActionDisplayName = "Modify", ActionName = "Modify", WorkflowName = "WorkflowName", WorkflowDisplayName = "WorkflowDisplayName", CreateDateTime = DateTime.Now, Id = Guid.NewGuid().ToString(), LastUpdateDateTime = DateTime.Now };
     OperationActionInfoModel queryEntity;
     using (var session = sessions.OpenSession())
     {
         session.Save(entity);
         session.Flush();
         queryEntity = session.Get<OperationActionInfoModel>(entity.Id);
         queryEntity.ActionDisplayName = "Modified";
         session.SaveOrUpdate(queryEntity);
         session.Flush();
         var result = session.Get<OperationActionInfoModel>(entity.Id);
         Assert.AreEqual(queryEntity.ActionDisplayName, result.ActionDisplayName);
     }
 }
        public void TestOperationActionInfoQueryByActionName()
        {
            var insertEntity = new OperationActionInfoModel { ActionDisplayName = "ActionDisplayName", ActionName = "ActionDisplayName", WorkflowName = "WorkflowName", WorkflowDisplayName = "WorkflowDisplayName", CreateDateTime = DateTime.Now, Id = Guid.NewGuid().ToString(), LastUpdateDateTime = DateTime.Now };

            using (var session = sessions.OpenSession())
            {
                session.Save(insertEntity);
                session.Flush();
                OperationActionInfoModel entity = null;
                var resultList = session.CreateQuery("from OperationActionInfoModel ").List<OperationActionInfoModel>();
                if (resultList.Count > 0)
                    entity = resultList.FirstOrDefault();
                ICriteria crit = session.CreateCriteria(typeof(OperationActionInfoModel)).Add(Restrictions.Eq("ActionName", entity.ActionName));
                var result = crit.List<OperationActionInfoModel>().First();
                Assert.AreEqual(result.ActionName, entity.ActionName);
            }
        }
 private void InitProperty(OperationActionInfoModel entity)
 {
     Id = entity.Id;
     CreateDateTime = entity.CreateDateTime;
     IsDelete = IsDelete;
 }