Exemplo n.º 1
0
        public override void DoCustomBinding()
        {
            if (MemberType == UserMemberType)
            {
                GroupId = null;
            }
            else if (MemberType == GroupMemberType)
            {
                UserId = null;
            }
            else
            {
                GroupId = null;
                UserId  = null;
            }

            if (IsNew)
            {
                if (MemberType == UserMemberType && UserId.HasValue)
                {
                    User = UserRepository.GetById(UserId.Value, true);
                }
                else if (MemberType == GroupMemberType && GroupId.HasValue)
                {
                    Group = UserGroupRepository.GetById(GroupId.Value);
                }
            }
        }
Exemplo n.º 2
0
        public MessageResult Remove(int id)
        {
            var group = UserGroupRepository.GetById(id);

            if (group == null)
            {
                throw new ApplicationException(string.Format(UserGroupStrings.GroupNotFound, id));
            }

            if (group.BuiltIn)
            {
                return(MessageResult.Error(UserGroupStrings.CannotRemoveBuitInGroup));
            }

            var notifications = new NotificationRepository().GetUserGroupNotifications(id).ToList();

            if (notifications.Any())
            {
                var message = string.Join(",", notifications.Select(w => $"({w.Id}) \"{w.Name}\""));
                return(MessageResult.Error(string.Format(UserGroupStrings.NotificationsExist, message)));
            }

            var workflows = WorkflowRepository.GetUserGroupWorkflows(id).ToList();

            if (workflows.Any())
            {
                var message = string.Join(",", workflows.Select(w => $"({w.Id}) \"{w.Name}\""));
                return(MessageResult.Error(string.Format(UserGroupStrings.WorkflowsExist, message)));
            }

            UserGroupRepository.Delete(id);
            return(null);
        }
Exemplo n.º 3
0
        public void GetByIdTest()
        {
            IUserGroupRepository target = new UserGroupRepository();
            var fromDb = target.GetById(item.Id);

            Assert.IsNotNull(fromDb);
            Assert.AreNotSame(item, fromDb);
            Assert.AreEqual(item.Descricao, fromDb.Descricao);
            Assert.AreEqual(item.Tipo, fromDb.Tipo);
        }
Exemplo n.º 4
0
        public UserGroup Read(int id)
        {
            var group = UserGroupRepository.GetById(id);

            if (group == null)
            {
                throw new ApplicationException(string.Format(UserGroupStrings.GroupNotFound, id));
            }

            return(group);
        }
Exemplo n.º 5
0
 public UserGroup GetById(object id)
 {
     return(_userGroupRepository.GetById(id));
 }