public Group AddGroup(long id, string description, Dictionary<int, bool> customActions)
        {
            try
            {
                using (var scope = new TransactionScope())
                {
                    var g = new Group(id, description, "");
                    //assignCustomActionsToParty(g,customActions);
                    //_userRepository.Add(g);
                    //scope.Complete();
                    return g;
                }
            }
            catch (Exception ex)
            {

                throw ex;
            }
        }
Example #2
0
        public void TestUserGroupsInsertion()
        {
            var user = new User(1, "User", "f", "l", "e", "fueluser");

            using (var ctx = new DataContainer())
            {
                ctx.Parties.Add(user);
                ctx.SaveChanges();

                var group = new Group(2, "Group", "Desc");
                ctx.Parties.Add(group);
                ctx.SaveChanges();

                user.AssignGroup(group);
                ctx.SaveChanges();
            }

            using (var ctx = new DataContainer())
            {
                var insertedUser = ctx.Parties.OfType<User>().Single(u => u.Id == 1);

                Assert.IsTrue(
                    insertedUser.Groups.Count == 1 &&
                    insertedUser.Groups.Count(g => g.Id == 2) == 1);

            }
        }
Example #3
0
 public virtual void RemoveGroup(Group group)
 {
     this.Groups.RemoveAll(g => g.Id == group.Id);
 }
Example #4
0
        public void TestGroupInsertion()
        {
            Group group = null;

            using (var ctx = new DataContainer())
            {
                group = new Group(1, "Party", "desc");

                ctx.Parties.Add(group);

                ctx.SaveChanges();
            }

            using (var ctx = new DataContainer())
            {
                var user2 = ctx.Parties.OfType<Group>().Single(u => u.Id == 1);

                Assert.AreEqual(group.Description, user2.Description);
            }
        }
Example #5
0
        public virtual void AssignGroup(Group group)
        {
            if (group == null)
                throw new NullReferenceException();

            if (this.Groups.Count(g => g.Id == group.Id) == 0)
                this.Groups.Add(group);
        }