コード例 #1
0
        public async System.Threading.Tasks.Task <ActionResult> AddNewGroup(AddNewGroupViewModel model)
        {
            if (ModelState.IsValid)
            {
                var group = new Models.Students.Group();
                group.Name = model.GroupName;
                db.Groups.Add(group);
                db.SaveChanges();


                for (int index = 0; index < model.CountOfStudent; index++)
                {
                    string password = Membership.GeneratePassword(15, 6);
                    var    student  = new ApplicationUser {
                        UserName = model.GroupName + "_" + index, GroupId = group.GroupId, PasswordTxt = password
                    };
                    var result = await UserManager.CreateAsync(student, password);

                    if (result.Succeeded)
                    {
                        await UserManager.AddToRoleAsync(student.Id, "student");
                    }
                    AddErrors(result);
                }
                return(RedirectToAction("Index", "Group"));
            }


            return(View(model));
        }
コード例 #2
0
 public ActionResult AddNewGroup(AddNewGroupViewModel model)
 {
     adminService.AddNewGroup(new Group()
     {
         GroupName = model.GroupName
     });
     return(RedirectToAction(nameof(GroupsPanel)));
 }
コード例 #3
0
ファイル: AddNewGroupView.xaml.cs プロジェクト: nrag/yapper
        private void ApplicationBarIconButton_Click(object sender, EventArgs e)
        {
            this.ApplicationBar.IsVisible = false;
            foreach (var b in this.ApplicationBar.Buttons)
            {
                ((ApplicationBarIconButton)b).IsEnabled = false;
            }

            AddNewGroupViewModel vm = (AddNewGroupViewModel)this.DataContext;

            vm.CreateNewGroup(this.GroupNameTextBox.Text, vm.SelectedMembers.ToList());
        }
コード例 #4
0
ファイル: AddNewGroupView.xaml.cs プロジェクト: nrag/yapper
        private void AddMemberApplicationBarDone_Click(object sender, EventArgs e)
        {
            this.ApplicationBar           = (ApplicationBar)this.Resources["MainpageApplicationBar"];
            this.ApplicationBar.IsVisible = true;

            AddNewGroupViewModel vm = (AddNewGroupViewModel)this.DataContext;

            foreach (object user in this.ContactsListSelector.SelectedItems)
            {
                vm.SelectedMembers.Add((UserModel)user);
            }

            this.SelectUserPopup.Visibility = System.Windows.Visibility.Collapsed;
            this.SelectUserPopup.IsOpen     = false;
        }