public DoctrinaGroup CreateGroup(CreateGroupViewModel model, string ownerId)
        {
            DoctrinaGroup result = new DoctrinaGroup
            {
                Name = model.Name
            };

            _db.Add <DoctrinaGroup>(result);
            _db.SaveChanges();

            _db.Entry(result).GetDatabaseValues();

            DoctrinaUserDoctrinaGroup newUserGroup = new DoctrinaUserDoctrinaGroup
            {
                DoctrinaGroupId  = result.Id,
                DoctrinaUserId   = ownerId,
                IsAdmin          = true,
                IsInvitePending  = false,
                IsRequestPending = false,
            };

            _db.Add <DoctrinaUserDoctrinaGroup>(newUserGroup);
            _db.SaveChanges();

            string folderPath = Path.Combine(_hostingEnvironment.WebRootPath, "DynamicResources/groups", result.Id);

            Directory.CreateDirectory(folderPath);

            return(result);
        }
        public void SendFriendRequest(DoctrinaUser user, DoctrinaUser friend)
        {
            Friendship userToFriend = new Friendship
            {
                UserId              = user.Id,
                FriendId            = friend.Id,
                IsInvitationPending = false,
                IsRequestPending    = true
            };

            Friendship friendToUser = new Friendship
            {
                UserId              = friend.Id,
                FriendId            = user.Id,
                IsInvitationPending = true,
                IsRequestPending    = false
            };

            _db.Add <Friendship>(userToFriend);
            _db.Add <Friendship>(friendToUser);
            _db.SaveChanges();
        }