public async Task <ActionResult <OrganizationPermission> > Delete(int id) { var movie = await _orgPermissionRepository.Delete(id); if (movie == null) { return(NotFound()); } return(movie); }
public async Task <ActionResult <User> > DeleteUserFromEntity(int entityId, int UserId, int invId) { var user = _userEntityRepository.GetByUserId(invId, entityId); Console.WriteLine(user.Role); var Newuser = _userEntityRepository.GetByUserId(UserId, entityId); Boolean admin = false; if (user.Role == Role.Manager) { admin = true; } if (admin) { if (!(Newuser is null)) { if (Newuser.Role != Role.Manager) { var user_entity = _userEntityRepository.GetByUserId(UserId, entityId); var wall = _wallRepository.GetByUserEntityId(UserId, entityId); var okr = _okrRepository.GetByUserEntityId(UserId, entityId); var org = _organizationRepository.GetOrgPermission(UserId, entityId); var notif = _notificationRepository.GetByUserEntityId(UserId, entityId); _userEntityRepository.Remove(user_entity.Id); await _wallRepository.Delete(wall.Id); await _okrRepository.Delete(okr.Id); if (!(org is null)) { await _organizationRepository.Delete(org.Id); } await _notificationRepository.Delete(notif.Id); return(Ok("deleted")); } else { return(Ok("you can't delete a manager for the entity")); } } else { return(Ok("this user does not have a role for this entity")); } }