Example #1
0
 public void AddUserToGroup(Group group, User user)
 {
     var currentGroup = _db.Groups.Find(group.IdGroup);
     var currentUser = _db.Users.Find(user.IdUser);
     currentGroup.Users.Add(currentUser);
     _db.SaveChanges();
 }
Example #2
0
 public Guid Insert(Group group)
 {
     var guid = Guid.NewGuid();
     group.IdGroup = guid;
     _db.Groups.Add(group);
     _db.SaveChanges();
     return guid;
 }
        public void SetUp()
        {
            _groupRepository = new GroupRepository(_db);
            _userRepository = new UserRepository(_db);
            _simpleGroup = new Group() { Name = "Name" };
            _simpleGroup.IdGroup = _groupRepository.Insert(_simpleGroup);

            _simpleUserOne = new User() { Name = "SimpleUserOne", Login = "******" };
            _simpleUserOne.IdUser = _userRepository.Insert(_simpleUserOne);
            _simpleUserTwo = new User() { Name = "SimpleUserTwo", Login  = "******" };
            _simpleUserTwo.IdUser = _userRepository.Insert(_simpleUserTwo);
            _simpleUserThree = new User() { Name = "SimpleUserThree", Login = "******"};
            _simpleUserThree.IdUser = _userRepository.Insert(_simpleUserThree);
        }
        public void SetUp()
        {
            _companyRepository = new CompanyRepository(_db);
            _groupRepository = new GroupRepository(_db);
            _simpleCompany = new Company() { Name = "New Co" };
            _simpleGroup = new Group() { Name = "Administrators" };

            _newCompany = new Company() { Name = "New Company" };
            _companyRepository.Insert(_newCompany);

            _groupIT = new Group() { Name = "IT" };
            _groupRepository.Insert(_groupIT);
            _groupMarketing = new Group() { Name = "Marketing" };
            _groupRepository.Insert(_groupMarketing);
            _groupManagement = new Group() { Name = "Management" };
            _groupRepository.Insert(_groupManagement);
        }
Example #5
0
 public void Update(Group group)
 {
     _db.Entry<Group>(group).State = System.Data.EntityState.Modified;
     _db.SaveChanges();
 }