public void DeleteFriendship(DoctrinaUser user, DoctrinaUser friend) { Friendship userToFriend = _db.Find <Friendship>(user.Id, friend.Id); Friendship friendToUser = _db.Find <Friendship>(friend.Id, user.Id); _db.Remove <Friendship>(userToFriend); _db.Remove <Friendship>(friendToUser); _db.SaveChanges(); }
public void DeleteGroup(string id) { DoctrinaGroup group = _db.Find <DoctrinaGroup>(id); IList <DoctrinaGroupSection> sections = _db.DoctrinaGroupSections.Where(s => s.DoctrinaGroup.Id == group.Id).ToList(); IList <DoctrinaUserDoctrinaGroup> userGroupRelations = _db.DoctrinaUserDoctrinaGroup.Where(gu => gu.DoctrinaGroupId == group.Id).ToList(); foreach (var section in sections) { DeleteSection(section.Id); } foreach (var relation in userGroupRelations) { _db.Remove <DoctrinaUserDoctrinaGroup>(relation); } string folderPath = Path.Combine(_hostingEnvironment.WebRootPath, "DynamicResources/groups", group.Id); Directory.Delete(folderPath); _db.Remove <DoctrinaGroup>(group); _db.SaveChanges(); }