Example #1
0
        public ActionResult AddToGroup(Guid id)
        {
            var user = _Storage.GetUser(u => u.Id == id);

            var groupList = _Storage.GetGroupsAvaliableForUser(user).Select(g => new SelectListItem { Text = g.Name, Value = g.Id.ToString(), Selected = false });

            var userGroup = new UserGroupModel { GroupList = groupList };

            return View(userGroup);
        }
Example #2
0
        public ActionResult AddToGroup(Guid id, int? groupRef)
        {
            var user = _Storage.GetUser(u => u.Id == id);

            if (groupRef == null)
            {
                var groupList = _Storage.GetGroupsAvaliableForUser(user).Select(g => new SelectListItem { Text = g.Name, Value = g.Id.ToString(), Selected = false });

                var userGroup = new UserGroupModel { GroupList = groupList };

                ModelState.AddModelError("GroupRef", "Please select group from list");

                return View(userGroup);
            }

            var group = _Storage.GetGroup(groupRef.Value);

            _Storage.AddUserToGroup(group, user);

            return RedirectToAction("Details", new { Id = id });
        }
Example #3
0
        public ActionResult AddUsersToGroup(string usersId, int? groupRef)
        {

            var ids = usersId.Split(',');

            List<Guid> usersIds = new List<Guid>();

            foreach (var id in ids)
            {
                try
                {
                    usersIds.Add(Guid.Parse(id));
                }
                catch (Exception)
                {

                }
            }

            if (groupRef == null)
            {
                var groupList =
                    this.storage.GetGroups().Select(
                    g => new SelectListItem { Text = g.Name, Value = g.Id.ToString(), Selected = false });

                var userGroup = new UserGroupModel { GroupList = groupList };

                this.ModelState.AddModelError("GroupRef", Localization.GetMessage("SelectGroup"));

                return this.View(userGroup);
            }

            var group = this.storage.GetGroup(groupRef.Value);

            var users = this.storage.GetUsers().Where(u => usersIds.Contains(u.Id) && this.storage.GetGroupsAvailableToUser(u).Any(g => g.Id == group.Id)).ToList();

            foreach (var user in users)
            {
                this.storage.AddUserToGroup(group, user);
            }

            return RedirectToAction("Index");
        }
Example #4
0
        public ActionResult AddUsersToGroup(string usersId)
        {
            var ids = usersId.Split(',');

            List<Guid> usersIds = new List<Guid>();

            foreach (var id in ids)
            {
                try
                {
                    usersIds.Add(Guid.Parse(id));
                }
                catch (Exception)
                {

                }

            }


            var groupList =
                this.storage.GetGroups().Select(
                    g => new SelectListItem { Text = g.Name, Value = g.Id.ToString(), Selected = false });

            var userGroup = new UserGroupModel { GroupList = groupList };

            return this.View(userGroup);
        }
Example #5
0
        public ActionResult AddToGroup(Guid id)
        {
            var user = this.storage.GetUser(u => u.Id == id);

            if (user == null)
            {
                return this.RedirectToAction("Index");
            }

            var groupList =
                this.storage.GetGroupsAvailableToUser(user).Select(
                    g => new SelectListItem { Text = g.Name, Value = g.Id.ToString(), Selected = false });

            var userGroup = new UserGroupModel { GroupList = groupList };

            return this.View(userGroup);
        }