public void Init()
        {
            IdentityHelper ihelper  = IdentityHelper.GetInstance();
            string         userName = "******";
            AppUser        user     = new AppUser
            {
                AccountName = userName,
                Name        = "James",
                Mobile      = "1888888888",
                Email       = "*****@*****.**"
            };
            string password = "******";
            var    dbUser   = database.Users.SingleOrDefault(u => u.AccountName == userName);

            if (dbUser != null)
            {
                //等一下注释掉这一句
                database.Users.Remove(dbUser);
                database.SaveChanges();
            }
            IdentityResult result = ihelper.CreateUser(user, password, AppRoleEnum.OrgnizationMember, OrganizationEnum.SEA团队);

            testclaims = ihelper.CreateClaims(userName, password, userName);
            helper     = VolunteerHelper.GetInstance(testclaims);
        }
        public void EditVolunteerTest()
        {
            #region init
            IdentityHelper ihelper  = IdentityHelper.GetInstance();
            string         userName = "******";
            AppUser        user     = new AppUser
            {
                AccountName = userName,
                Name        = "James",
                Mobile      = "1888888888",
                Email       = "*****@*****.**"
            };
            string  password = "******";
            AppUser dbUser   = database.Users.SingleOrDefault(u => u.AccountName == userName);
            if (dbUser != null)
            {
                database.Users.Remove(dbUser);
                database.SaveChanges();
            }
            IdentityResult result1 = ihelper.CreateUser(user, password, AppRoleEnum.OrgnizationMember, OrganizationEnum.SEA团队);
            testclaims = ihelper.CreateClaims(userName, password, userName);
            helper     = VolunteerHelper.GetInstance(testclaims);
            #endregion
            #region 新建一个志愿者对象
            Volunteer v = new Volunteer
            {
                StudentNum = 0401,
                Name       = "EditTestName",
                Class      = "TestClass",
                Email      = "*****@*****.**",
                Room       = "testroom"
            };
            helper.AddVolunteer(v);
            #endregion

            #region 第一次修改
            v.Name = "ModifiedEditTestName";
            var tempvolunteer = helper.FindVolunteer(v.StudentNum);
            helper.EditVolunteer(tempvolunteer, v);//需要重建一个volunteer实体,因为实体v在加入数据库之后会自动更新链接到数据库中的条目。
            tempvolunteer = helper.FindVolunteer(v.StudentNum);
            if (!Volunteer.AreSame(v, tempvolunteer))
            {
                Assert.Fail("修改志愿者信息失败");
            }
            #endregion

            #region 第二次修改
            v.Name        = "EditByParamTestName";
            tempvolunteer = helper.FindVolunteer(v.StudentNum);
            helper.EditVolunteer(tempvolunteer, v.StudentNum, v.Name);
            tempvolunteer = helper.FindVolunteer(v.StudentNum);
            if (!Volunteer.AreSame(v, tempvolunteer))
            {
                Assert.Fail("第二次修改志愿者信息失败");
            }
            #endregion
            var result3 = helper.FindVolunteer(v.StudentNum);
            database.Volunteers.Remove(result3);//Remove
        }
 public Csvviewer(Project p, List <csvItemViewModel> list, InputWindow window)//csv导入后弹出,加载页面=>datagrid列表显示,若有冲突:"一个以上冲突,请您确认",对应行标红,保留与否:按钮.保留原数据/新数据,下一步:更改的确认,导入成功,detail页面的显示
 {
     InitializeComponent();
     fatherWindow = window;
     vhelper      = VolunteerHelper.GetInstance();
     pphelper     = ProjectProgressHelper.GetInstance();
     project      = p;
     chelper      = CsvHelper.GetInstance();
     csvList      = list;
     ShowCddGrid();
     Claims = identitypage.Claims;
 }
        public void Init()
        {
            AppUser user     = CreateUser();
            string  password = "******";
            var     dbUser   = database.Users.SingleOrDefault(u => u.AccountName == user.AccountName);

            if (dbUser != null)
            {
                //等一下注释掉这一句
                database.Users.Remove(dbUser);
                database.SaveChanges();
            }
            IdentityResult result = identityhelper.CreateUser(user, password, Interface.AppRoleEnum.OrgnizationMember, OrganizationEnum.SEA团队);

            testclaims      = identityhelper.CreateClaims(user.AccountName, password);
            volunteerhelper = VolunteerHelper.GetInstance(testclaims);
        }
 private void searchbyid_btn_Click(object sender, RoutedEventArgs e)
 {
     if (studentnum == null)
     {
     }
     else
     {
         var vh = VolunteerHelper.GetInstance();
         if (studentnum.Text != "")
         {
             try
             {
                 int num = int.Parse(studentnum.Text);
                 sourceList.Add(vh.FindVolunteer(num));
                 Volunteerdata.ItemsSource = sourceList;
             }
             catch (Exception)
             {
                 ModernDialog.ShowMessage("学号输入非法,仅能输入数字.", "警告", MessageBoxButton.OK);
             }
         }
     }
 }