Ejemplo n.º 1
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);
        }
Ejemplo n.º 2
0
        // GET: Group/GroupEdit/5
        public ActionResult GroupEdit(long? id)
        {
            if (!IsAuthorized())
                return new HttpStatusCodeResult(HttpStatusCode.Forbidden);
            if (id == null)
            {
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            }
            Group grp = um.FindGroup(id.Value);

            if (grp == null)
            {
                return HttpNotFound();
            }

            List<EntitySelectedViewModel> users = new List<EntitySelectedViewModel>();

            var mod = new AdminEditGroupViewModel();
            mod.Id = grp.Id;
            mod.Name = grp.Name;
            mod.Description = grp.Description;
            var userList = um.Context.Users.ToList();
            foreach (User u in userList)
            {
                if (u.Name.Equals("__DEFAULT__") || u.State == ObjectState.Deleted) { continue; }
                var a = new EntitySelectedViewModel();
                a.Id = u.Id;
                a.IsSelected = grp.Users.Contains(u);
                a.Name = u.Name;
                users.Add(a);
            }
            mod.Users = users;
            return View(mod);
        }
Ejemplo n.º 3
0
        public ActionResult Index(string fullName)
        {
            if (fullName == null)
                return RedirectToAction("Browse", "File", null);

            Folder userRootFolder = _fileManager.GetUserRootFolder(User.Identity.GetUserId());
            User currentUser = _userManager.FindUser(User.Identity.GetUserId());
            string fullDisplayName;
            File file = _fileManager.FindFile(fullName, userRootFolder, out fullDisplayName);

            if (file == null || file is Document)
            {
                return HttpNotFound();
            }

            Folder folder = (Folder)file;

            if (DetermineDisallowedReason(folder) != InvitationDisallowedReason.None)
                return new HttpStatusCodeResult(System.Net.HttpStatusCode.Forbidden);

            var mod = new EditInvitationsViewModel();

            mod.FullName = fullName;
            mod.FromPath = _fileManager.GetFullDisplayName(file.ParentFolder, userRootFolder);

            var invitations = _fileManager.Context.Invitations.ToList();
            foreach (Invitation i in invitations)
            {
                if (i.TargetId == folder.Id)
                {
                    var ivm = new InvitationVM
                    {
                        Id = i.Id,
                        UserName = i.User.Name,
                        Timestamp = i.TimeStamp,
                        Accepted = i.AcceptedFolders.Any()
                    };
                    mod.FolderInvitations.Add(ivm);
                }
            }

            var uninvited = uninvitedUsers(fullName);
            foreach (User u in uninvited)
            {
                if (u == _userManager.GetDefaultUser() ||
                    u.State == ObjectState.Deleted ||
                    u == currentUser) continue;
                var e = new EntitySelectedViewModel
                {
                    Id = u.Id,
                    IsSelected = false,
                    Name = u.Name
                };
                mod.UsersToInvite.Add(e);
            }

            foreach (Group g in _userManager.Context.Groups)
            {
                if (g.State == ObjectState.Deleted) continue;
                var e = new EntitySelectedViewModel
                {
                    Id = g.Id,
                    IsSelected = false,
                    Name = g.Name
                };
                mod.GroupsToInvite.Add(e);
            }

            ViewBag.Subheading = folder.DisplayName;
            return View(mod);
        }