public bool Invoke(int id) { var userToDelete = userRepository.GetById(id); if (userToDelete == null) { return(false); } userRepository.Delete(userToDelete); userRepository.Save(); var userApps = userAppRepository.GetAll(); var appsToDelete = (from app in userApps where app.User.Id == id select app).ToList(); if (appsToDelete == null || appsToDelete.Count == 0) { return(false); } foreach (var app in appsToDelete) { userAppRepository.Delete(app); } userAppRepository.Save(); return(true); }
public bool Invoke(int userId, int appId) { var appToDelete = userAppRepository.FindBy(x => x.User.Id == userId && x.App.Id == appId).FirstOrDefault(); if (appToDelete == null) { return(false); } userAppRepository.Delete(appToDelete); userAppRepository.Save(); return(true); }