コード例 #1
0
        public ActionResult GroupCreate(AdminNewGroupViewModel model)
        {
            if (!IsAuthorized())
                return new HttpStatusCodeResult(HttpStatusCode.Forbidden);
            Group template = null;
            if (ModelState.IsValid)
            {
                template = new Group
                {
                    Name = model.Name,
                    Description = model.Description,
                    IsAdmin = false
                };
                var actual = um.CreateGroup(template);
                actual.Users.Add(um.GetDefaultUser());
                foreach (var item in model.Users)
                {
                    if (item.IsSelected)
                    {
                        FooBox.User u = um.FindUser(item.Id);
                        if (u != null) actual.Users.Add(u);
                        um.Context.SaveChanges();
                    }
                }

                DisplaySuccessMessage("User created");
                return RedirectToAction("Index");
            }

            DisplayErrorMessage();
            return View(model);
        }
コード例 #2
0
        // GET: Group/GroupCreate
        public ActionResult GroupCreate()
        {
            var mod = new AdminNewGroupViewModel();
            List<EntitySelectedViewModel> users = new List<EntitySelectedViewModel>();

            foreach (User u in um.Context.Users)
            {
                if (u.Name.Equals("__DEFAULT__") || u.State == ObjectState.Deleted) { continue; }
                var a = new EntitySelectedViewModel();
                a.Id = u.Id;
                a.IsSelected = false;
                a.Name = u.Name;
                users.Add(a);
            }
            mod.Users = users;
            return View(mod);
        }